summaryrefslogtreecommitdiff
path: root/lib/socket_wrapper
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2010-10-10 12:29:08 +0200
committerMatthieu Patou <mat@samba.org>2010-10-10 12:56:59 +0000
commit9b9489479e9c429cefd58c31be4d39da8ea90057 (patch)
tree9cdb368c965e017068eb0e32e4aa68b8939db9c4 /lib/socket_wrapper
parent9d958ce582fa760456b52d65a2deb36d8bd3794a (diff)
downloadsamba-9b9489479e9c429cefd58c31be4d39da8ea90057.tar.gz
samba-9b9489479e9c429cefd58c31be4d39da8ea90057.tar.bz2
samba-9b9489479e9c429cefd58c31be4d39da8ea90057.zip
socket_wrapper: Make it work on freebsd for udp packets
Autobuild-User: Matthieu Patou <mat@samba.org> Autobuild-Date: Sun Oct 10 12:57:00 UTC 2010 on sn-devel-104
Diffstat (limited to 'lib/socket_wrapper')
-rw-r--r--lib/socket_wrapper/socket_wrapper.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c
index 9d732ee652..c52d98cf91 100644
--- a/lib/socket_wrapper/socket_wrapper.c
+++ b/lib/socket_wrapper/socket_wrapper.c
@@ -1967,7 +1967,17 @@ _PUBLIC_ ssize_t swrap_sendto(int s, const void *buf, size_t len, int flags, con
si->defer_connect = 0;
}
- ret = real_sendto(s, buf, len, flags, (struct sockaddr *)&un_addr, sizeof(un_addr));
+ /* Man page for Linux says:
+ * "the error EISONN may be returned when they are not NULL and 0"
+ * But in practice it's not on x86/amd64, but on other unix it is
+ * (ie. freebsd)
+ * So if we are already connected we send NULL/0
+ */
+ if (si->connected) {
+ ret = real_sendto(s, buf, len, flags, NULL, 0);
+ } else {
+ ret = real_sendto(s, buf, len, flags, (struct sockaddr *)&un_addr, sizeof(un_addr));
+ }
break;
default:
ret = -1;