From 9b9489479e9c429cefd58c31be4d39da8ea90057 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 10 Oct 2010 12:29:08 +0200 Subject: socket_wrapper: Make it work on freebsd for udp packets Autobuild-User: Matthieu Patou Autobuild-Date: Sun Oct 10 12:57:00 UTC 2010 on sn-devel-104 --- lib/socket_wrapper/socket_wrapper.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/socket_wrapper/socket_wrapper.c') 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; -- cgit