From 98852bd4272efffc197f122b3b448b8c2e7d675f Mon Sep 17 00:00:00 2001 From: Eric Warmenhoven Date: Tue, 3 Jun 2025 23:02:57 -0400 Subject: [PATCH] android: enable builtin mbed-tls fixes #16847 --- libretro-common/net/net_http.c | 53 +++++++++++++---------- pkg/android/phoenix-common/jni/Android.mk | 3 +- tasks/task_cloudsync.c | 3 ++ 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index c0332a18c6..5e501685e9 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -973,40 +973,45 @@ static bool net_http_connect(struct http_t *state) #else if (state->ssl) { - if (!conn || conn->fd < 0) + if (!conn) return false; - if (!(conn->ssl_ctx = ssl_socket_init(conn->fd, state->request.domain))) + for (next_addr = addr; conn->fd >= 0; conn->fd = socket_next((void**)&next_addr)) { - net_http_conn_pool_remove(conn); - state->conn = NULL; - state->error = true; - return false; - } + if (!(conn->ssl_ctx = ssl_socket_init(conn->fd, state->request.domain))) + { + socket_close(conn->fd); + break; + } - /* TODO: Properly figure out what's going wrong when the newer - timeout/poll code interacts with mbed and winsock - https://github.com/libretro/RetroArch/issues/14742 */ + /* TODO: Properly figure out what's going wrong when the newer + timeout/poll code interacts with mbed and winsock + https://github.com/libretro/RetroArch/issues/14742 */ - /* Temp fix, don't use new timeout/poll code for cheevos http requests */ + /* Temp fix, don't use new timeout/poll code for cheevos http requests */ bool timeout = true; #ifdef __WIN32 - if (!strcmp(state->request.domain, "retroachievements.org")) - timeout = false; + if (!strcmp(state->request.domain, "retroachievements.org")) + timeout = false; #endif - if (ssl_socket_connect(conn->ssl_ctx, addr, timeout, true) < 0) - { - net_http_conn_pool_remove(conn); - state->conn = NULL; - state->error = true; - return false; - } - else - { - conn->connected = true; - return true; + if (ssl_socket_connect(conn->ssl_ctx, next_addr, timeout, true) < 0) + { + ssl_socket_close(conn->ssl_ctx); + ssl_socket_free(conn->ssl_ctx); + conn->ssl_ctx = NULL; + } + else + { + conn->connected = true; + return true; + } } + conn->fd = -1; /* already closed */ + net_http_conn_pool_remove(conn); + state->conn = NULL; + state->error = true; + return false; } else #endif diff --git a/pkg/android/phoenix-common/jni/Android.mk b/pkg/android/phoenix-common/jni/Android.mk index 843d2fbfb4..9c1232ed03 100644 --- a/pkg/android/phoenix-common/jni/Android.mk +++ b/pkg/android/phoenix-common/jni/Android.mk @@ -137,7 +137,8 @@ DEFINES += -DRARCH_MOBILE \ -DHAVE_TRANSLATE \ -DWANT_IFADDRS \ -DHAVE_XDELTA \ - -DHAVE_CORE_INFO_CACHE + -DHAVE_CORE_INFO_CACHE \ + -DHAVE_BUILTINMBEDTLS -DHAVE_SSL ifeq ($(HAVE_GFX_WIDGETS),1) DEFINES += -DHAVE_GFX_WIDGETS diff --git a/tasks/task_cloudsync.c b/tasks/task_cloudsync.c index c3bae6165f..b369aee659 100644 --- a/tasks/task_cloudsync.c +++ b/tasks/task_cloudsync.c @@ -1244,6 +1244,9 @@ static void task_cloud_sync_task_handler(retro_task_t *task) } slock_unlock(tcs_running_lock); + if (task->flags & RETRO_TASK_FLG_FINISHED) + goto task_finished; + switch (sync_state->phase) { case CLOUD_SYNC_PHASE_BEGIN: