From: Anthony Minessale Date: Tue, 16 Oct 2007 01:08:51 +0000 (+0000) Subject: wait there's more X-Git-Tag: v1.0-beta2~482 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b9a0327d00dab6d8a5edda917b32c8f2ec43efd;p=thirdparty%2Ffreeswitch.git wait there's more git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5884 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- diff --git a/src/switch_apr.c b/src/switch_apr.c index 13edebbf37..c1b473ebc1 100644 --- a/src/switch_apr.c +++ b/src/switch_apr.c @@ -561,18 +561,24 @@ SWITCH_DECLARE(switch_status_t) switch_socket_connect(switch_socket_t * sock, sw SWITCH_DECLARE(switch_status_t) switch_socket_send(switch_socket_t * sock, const char *buf, switch_size_t *len) { - switch_status_t status; - switch_size_t req = *len, wrote = 0, need = 0; - - status = apr_socket_send(sock, buf, len); - if (status == SWITCH_STATUS_SUCCESS) { - wrote = *len; - while (wrote < req && status == SWITCH_STATUS_SUCCESS) { - need = req - wrote; - status = apr_socket_send(sock, buf + wrote, &need); - wrote += need; + switch_status_t status = SWITCH_STATUS_SUCCESS; + switch_size_t req = *len, wrote = 0, need = *len; + int to_count = 0; + + while ((wrote < req && status == SWITCH_STATUS_SUCCESS) || (need == 0 && status == SWITCH_STATUS_BREAK)) { + need = req - wrote; + if ((status = apr_socket_send(sock, buf + wrote, &need)) == SWITCH_STATUS_BREAK) { + if (++to_count > 10000) { + status = SWITCH_STATUS_FALSE; + break; + } + switch_yield(1000); + } else { + to_count = 0; } + wrote += need; } + *len = wrote; return status;