summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2013-03-04 14:06:14 +1100
committerStefan Metzmacher <metze@samba.org>2013-03-04 11:15:35 +0100
commit70e1b6185e3fb35fdc72eeb529ffb4b50122dc40 (patch)
tree5f5b0af8467570dc84ad2e85aec8e51c419ae07c /lib
parent50b42d1c5bb19e3a5050d7d23ac96e273d3974ee (diff)
downloadsamba-70e1b6185e3fb35fdc72eeb529ffb4b50122dc40.tar.gz
samba-70e1b6185e3fb35fdc72eeb529ffb4b50122dc40.tar.bz2
samba-70e1b6185e3fb35fdc72eeb529ffb4b50122dc40.zip
tsocket_bsd: Attempt to increase the SO_SNDBUF if we get EMSGSIZE in sendto()
This matches what was done for lib/socket/socket_unix.c in c692bb02b039ae8fef6ba968fd13b36ad7d62a72. (and is based on that patch by Landon Fuller <landonf@bikemonkey.org>) Andrew Bartlett Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Mon Mar 4 11:15:35 CET 2013 on sn-devel-104
Diffstat (limited to 'lib')
-rw-r--r--lib/tsocket/tsocket_bsd.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c
index 56dff68dd2..4b54d319a0 100644
--- a/lib/tsocket/tsocket_bsd.c
+++ b/lib/tsocket/tsocket_bsd.c
@@ -1102,6 +1102,32 @@ static void tdgram_bsd_sendto_handler(void *private_data)
/* retry later */
return;
}
+
+ if (err == EMSGSIZE) {
+ /* round up in 1K increments */
+ int bufsize = ((state->len + 1023) & (~1023));
+
+ ret = setsockopt(bsds->fd, SOL_SOCKET, SO_SNDBUF, &bufsize,
+ sizeof(bufsize));
+ if (ret == 0) {
+ /*
+ * We do the rety here, rather then via the
+ * handler, as we only want to retry once for
+ * this condition, so if there is a mismatch
+ * between what setsockopt() accepts and what can
+ * actually be sent, we do not end up in a
+ * loop.
+ */
+
+ ret = sendto(bsds->fd, state->buf, state->len,
+ 0, sa, sa_socklen);
+ err = tsocket_bsd_error_from_errno(ret, errno, &retry);
+ if (retry) { /* retry later */
+ return;
+ }
+ }
+ }
+
if (tevent_req_error(req, err)) {
return;
}