diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index cb2691c2a1..63605e55a1 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Wed Sep 24 01:09:42 CDT 2014 +Thu Sep 25 21:43:53 CDT 2014 diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c index 2fcd7021c0..7f4318e543 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c @@ -332,19 +332,22 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block) ssize_t r; int err = 0; + wsh->x++; + if (wsh->x > 250) ms_sleep(1); + if (wsh->ssl) { do { r = SSL_read(wsh->ssl, data, bytes); - ms_sleep(10); - if (r == -1) { err = SSL_get_error(wsh->ssl, r); - + if (!block && err == SSL_ERROR_WANT_READ) { r = -2; goto end; } + + if (block) ms_sleep(10); } } while (r == -1 && err == SSL_ERROR_WANT_READ && wsh->x < 100); @@ -354,10 +357,17 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block) do { r = recv(wsh->sock, data, bytes, 0); - ms_sleep(10); + if (r == -1) { + if (!block && xp_is_blocking(xp_errno())) { + r = -2; + goto end; + } + + if (block) ms_sleep(10); + } } while (r == -1 && xp_is_blocking(xp_errno()) && wsh->x < 100); - if (wsh->x >= 100) { + if (wsh->x >= 1000 || (block && wsh->x >= 100)) { r = -1; } diff --git a/src/mod/endpoints/mod_verto/ws.c b/src/mod/endpoints/mod_verto/ws.c index 2fcd7021c0..7f4318e543 100644 --- a/src/mod/endpoints/mod_verto/ws.c +++ b/src/mod/endpoints/mod_verto/ws.c @@ -332,19 +332,22 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block) ssize_t r; int err = 0; + wsh->x++; + if (wsh->x > 250) ms_sleep(1); + if (wsh->ssl) { do { r = SSL_read(wsh->ssl, data, bytes); - ms_sleep(10); - if (r == -1) { err = SSL_get_error(wsh->ssl, r); - + if (!block && err == SSL_ERROR_WANT_READ) { r = -2; goto end; } + + if (block) ms_sleep(10); } } while (r == -1 && err == SSL_ERROR_WANT_READ && wsh->x < 100); @@ -354,10 +357,17 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block) do { r = recv(wsh->sock, data, bytes, 0); - ms_sleep(10); + if (r == -1) { + if (!block && xp_is_blocking(xp_errno())) { + r = -2; + goto end; + } + + if (block) ms_sleep(10); + } } while (r == -1 && xp_is_blocking(xp_errno()) && wsh->x < 100); - if (wsh->x >= 100) { + if (wsh->x >= 1000 || (block && wsh->x >= 100)) { r = -1; }