]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix ssl connect race
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 27 Jun 2013 03:10:19 +0000 (23:10 -0400)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 27 Jun 2013 03:10:19 +0000 (23:10 -0400)
libs/sofia-sip/.update
libs/sofia-sip/libsofia-sip-ua/tport/ws.c

index 0440205a5353ed6b21bdca805d7423cd3ed6a091..d8abd49c6deb7a050761ecf84a3f0d04e3495da6 100644 (file)
@@ -1 +1 @@
-Wed Jun 26 12:43:51 EDT 2013
+Wed Jun 26 23:10:11 EDT 2013
index 46e41d133bc6c5596f88ffca7b7eafe829392417..1a0a2f3250fb11631b951955b6678bcdd282787c 100644 (file)
@@ -379,7 +379,8 @@ int ws_init(wsh_t *wsh, ws_socket_t sock, size_t buflen, SSL_CTX *ssl_ctx, int c
 
        if (wsh->secure) {
                int code;
-
+               int sanity = 500;
+               
                wsh->ssl = SSL_new(ssl_ctx);
                assert(wsh->ssl);
 
@@ -387,8 +388,32 @@ int ws_init(wsh_t *wsh, ws_socket_t sock, size_t buflen, SSL_CTX *ssl_ctx, int c
 
                do {
                        code = SSL_accept(wsh->ssl);
-               } while (code == -1 && SSL_get_error(wsh->ssl, code) == SSL_ERROR_WANT_READ);
 
+                       if (code == 1) {
+                               break;
+                       }
+
+                       if (code == 0) {
+                               return -1;
+                       }
+                       
+                       if (code < 0) {
+                               if (code == -1 && SSL_get_error(wsh->ssl, code) != SSL_ERROR_WANT_READ) {
+                                       return -1;
+                               }
+                       }
+#ifndef _MSC_VER
+                               usleep(10000);
+#else
+                               Sleep(10);
+#endif                         
+                               
+               } while (--sanity > 0);
+               
+               if (!sanity) {
+                       return -1;
+               }
+               
        }
 
        while (!wsh->down && !wsh->handshake) {