From: Nikos Mavrogiannopoulos Date: Mon, 23 Mar 2015 21:29:23 +0000 (+0100) Subject: Added a tight loop around the legacy push function X-Git-Tag: gnutls_3_4_0~101 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a98a905bc6ea03d5a758d98ef314a602720035da;p=thirdparty%2Fgnutls.git Added a tight loop around the legacy push function That reduces the need for more expensive outer loops. Originally suggested by Anton Lavrentiev. --- diff --git a/lib/gnutls_buffers.c b/lib/gnutls_buffers.c index ba2353936f..37d0a89234 100644 --- a/lib/gnutls_buffers.c +++ b/lib/gnutls_buffers.c @@ -440,9 +440,22 @@ _gnutls_writev_emu(gnutls_session_t session, gnutls_transport_ptr_t fd, if (vec) { ret = session->internals.vec_push_func(fd, &giovec[j], 1); } else { - ret = - session->internals.push_func(fd, giovec[j].iov_base, - giovec[j].iov_len); + size_t sent = 0; + ssize_t left = giovec[j].iov_len; + char *p = giovec[j].iov_base; + do { + ret = + session->internals.push_func(fd, p, + left); + if (ret > 0) { + sent += ret; + left -= ret; + p += ret; + } + } while(ret > 0 && left > 0); + + if (sent > 0) + ret = sent; } if (ret == -1) {