@@ -973,40 +973,45 @@ static bool net_http_connect(struct http_t *state)
973973#else
974974 if (state -> ssl )
975975 {
976- if (!conn || conn -> fd < 0 )
976+ if (!conn )
977977 return false;
978978
979- if (!( conn -> ssl_ctx = ssl_socket_init ( conn -> fd , state -> request . domain ) ))
979+ for ( next_addr = addr ; conn -> fd >= 0 ; conn -> fd = socket_next (( void * * ) & next_addr ))
980980 {
981- net_http_conn_pool_remove ( conn );
982- state -> conn = NULL ;
983- state -> error = true ;
984- return false ;
985- }
981+ if (!( conn -> ssl_ctx = ssl_socket_init ( conn -> fd , state -> request . domain )))
982+ {
983+ socket_close ( conn -> fd ) ;
984+ break ;
985+ }
986986
987- /* TODO: Properly figure out what's going wrong when the newer
988- timeout/poll code interacts with mbed and winsock
989- https://github.com/libretro/RetroArch/issues/14742 */
987+ /* TODO: Properly figure out what's going wrong when the newer
988+ timeout/poll code interacts with mbed and winsock
989+ https://github.com/libretro/RetroArch/issues/14742 */
990990
991- /* Temp fix, don't use new timeout/poll code for cheevos http requests */
991+ /* Temp fix, don't use new timeout/poll code for cheevos http requests */
992992 bool timeout = true;
993993#ifdef __WIN32
994- if (!strcmp (state -> request .domain , "retroachievements.org" ))
995- timeout = false;
994+ if (!strcmp (state -> request .domain , "retroachievements.org" ))
995+ timeout = false;
996996#endif
997997
998- if (ssl_socket_connect (conn -> ssl_ctx , addr , timeout , true) < 0 )
999- {
1000- net_http_conn_pool_remove (conn );
1001- state -> conn = NULL ;
1002- state -> error = true ;
1003- return false;
1004- }
1005- else
1006- {
1007- conn -> connected = true;
1008- return true;
998+ if (ssl_socket_connect (conn -> ssl_ctx , next_addr , timeout , true) < 0 )
999+ {
1000+ ssl_socket_close (conn -> ssl_ctx );
1001+ ssl_socket_free ( conn -> ssl_ctx ) ;
1002+ conn -> ssl_ctx = NULL ;
1003+ }
1004+ else
1005+ {
1006+ conn -> connected = true;
1007+ return true;
1008+ }
10091009 }
1010+ conn -> fd = -1 ; /* already closed */
1011+ net_http_conn_pool_remove (conn );
1012+ state -> conn = NULL ;
1013+ state -> error = true;
1014+ return false;
10101015 }
10111016 else
10121017#endif
0 commit comments