From cc755476727247c1e0f17e8b7fbed1fb717a02a5 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sat, 12 Jul 2014 04:39:41 +0500 Subject: [PATCH] merge ws.c change to sofia --- libs/sofia-sip/libsofia-sip-ua/tport/ws.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c index 11b92945c8..0ee867dba5 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c @@ -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));