]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix apr send func not sending all the bytes we asked it to.
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 15 Oct 2007 23:49:05 +0000 (23:49 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 15 Oct 2007 23:49:05 +0000 (23:49 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5883 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_apr.c

index 6c11e6d336be1a7887b0a88dfd7e173ab9936f42..13edebbf37e95653499d42172f17debec7111d95 100644 (file)
@@ -561,7 +561,21 @@ 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)
 {
-       return apr_socket_send(sock, buf, 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;
+               }
+       }
+       *len = wrote;
+       return status;
+
 }
 
 SWITCH_DECLARE(switch_status_t) switch_socket_sendto(switch_socket_t * sock, switch_sockaddr_t * where, int32_t flags, const char *buf, switch_size_t *len)