Patch: fix unix sockets under FreeBSD

Maxim Dounin mdounin at mdounin.ru
Wed Oct 3 02:19:33 UTC 2007


Hello!

Attached patch fixes unix sockets support under FreeBSD (and probably 
other *BSD's too, not checked). Should apply cleanly to trunk.

Problem background:

FreeBSD's sendmsg() requires msg_name in msghdr structure to be NULL if 
not used, setting msg_namelen to 0 isn't enough.

Maxim Dounin
-------------- next part --------------

# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1191375282 -14400
# Node ID 0b6ac95a09bb0dc005999f03f870ebab72bb4c5e
# Parent e28ab6bd21fa406dbfaa5ee771cbbf83e0f3e6a3
Fix unix sockets support under FreeBSD.

--- a/memcached.c	Sun Sep 30 04:14:57 2007 +0400
+++ b/memcached.c	Wed Oct 03 05:34:42 2007 +0400
@@ -219,8 +219,11 @@ static int add_msghdr(conn *c)
     memset(msg, 0, sizeof(struct msghdr));
 
     msg->msg_iov = &c->iov[c->iovused];
-    msg->msg_name = &c->request_addr;
-    msg->msg_namelen = c->request_addr_size;
+
+    if (c->request_addr_size > 0) {
+        msg->msg_name = &c->request_addr;
+        msg->msg_namelen = c->request_addr_size;
+    }
 
     c->msgbytes = 0;
     c->msgused++;



More information about the memcached mailing list