diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2015-01-05 15:08:28 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2015-01-05 16:30:42 +0100 |
commit | 43082a67c7514d65301d157fb567a133138a85ab (patch) | |
tree | 8d626158f3f880c73ee9a129969cebcc3f174011 /lib/gnutls_buffers.c | |
parent | 7be51ddf6b861247e36f9a981739170a168fa712 (diff) | |
download | gnutls-43082a67c7514d65301d157fb567a133138a85ab.tar.gz |
in DTLS don't use writev() when multiple packets which exceed MTU are queued
That change requires the system_write() to be registered unconditionally,
even when writev() is available.
Resolves: https://savannah.gnu.org/support/?108715
Diffstat (limited to 'lib/gnutls_buffers.c')
-rw-r--r-- | lib/gnutls_buffers.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/gnutls_buffers.c b/lib/gnutls_buffers.c index 24e52b1b96..ef2ad236b3 100644 --- a/lib/gnutls_buffers.c +++ b/lib/gnutls_buffers.c @@ -460,14 +460,30 @@ _gnutls_writev_emu(gnutls_session_t session, gnutls_transport_ptr_t fd, static ssize_t _gnutls_writev(gnutls_session_t session, const giovec_t * giovec, - int giovec_cnt) + unsigned giovec_cnt) { int i; + bool is_dtls = IS_DTLS(session); + bool no_writev = 0; gnutls_transport_ptr_t fd = session->internals.transport_send_ptr; reset_errno(session); - if (session->internals.push_func != NULL) + /* In DTLS we use writev() only when the total sum is less than + * the MTU. */ + + if (is_dtls && giovec_cnt > 1) { + unsigned sum = 0, j; + for (j = 0; j < giovec_cnt; j++) { + sum += giovec[j].iov_len; + } + + if (sum > session->internals.dtls.mtu) { + no_writev = 1; + } + } + + if (session->internals.push_func != NULL || no_writev != 0) i = _gnutls_writev_emu(session, fd, giovec, giovec_cnt); else i = session->internals.vec_push_func(fd, giovec, @@ -477,7 +493,7 @@ _gnutls_writev(gnutls_session_t session, const giovec_t * giovec, int err = get_errno(session); _gnutls_debug_log("errno: %d\n", err); - return errno_to_gerr(err, IS_DTLS(session)); + return errno_to_gerr(err, is_dtls); } return i; } |