]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
merge ws.c change to sofia
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 11 Jul 2014 23:39:41 +0000 (04:39 +0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 11 Jul 2014 23:39:41 +0000 (04:39 +0500)
libs/sofia-sip/libsofia-sip-ua/tport/ws.c

index 11b92945c890f03207e669175a43075b83bdaca3..0ee867dba52adab50842ab65efb0debb3bfcc502 100644 (file)
@@ -368,18 +368,25 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block)
 ssize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes)
 {
        size_t r;
+       int sanity = 2000;
 
        if (wsh->ssl) {
                do {
                        r = SSL_write(wsh->ssl, data, bytes);
-               } while (r == -1 && SSL_get_error(wsh->ssl, r) == SSL_ERROR_WANT_WRITE);
+                       if (sanity < 2000) {
+                               ms_sleep(1);
+                       }
+               } while (--sanity > 0 && r == -1 && SSL_get_error(wsh->ssl, r) == SSL_ERROR_WANT_WRITE);
 
                return r;
        }
 
        do {
                r = send(wsh->sock, data, bytes, 0);
-       } while (r == -1 && xp_is_blocking(xp_errno()));
+               if (sanity < 2000) {
+                       ms_sleep(1);
+               }
+       } while (--sanity > 0 && r == -1 && xp_is_blocking(xp_errno()));
 
        //if (r<0) {
                //printf("wRITE FAIL: %s\n", strerror(errno));