tags patch

(^ no idea if that works)

Here's a patch that also fixes up the receiving of control messages when
they aren't from inet sockets.

--- a/lib/eunuchs/sendmsg.c     (revision 16)
+++ b/lib/eunuchs/sendmsg.c     (working copy)
@@ -16,8 +16,8 @@
   struct iovec iov[1];
   char cmsgbuf[CMSG_BUFSIZE];
   PyObject *ancillary = NULL;
-  char *host;
-  int port;
+  char *host = NULL;
+  int port = 0;
 
   static char *kwlist[] = {"fd",
                           "data",
@@ -26,7 +26,7 @@
                           "ancillary",
                           NULL};
 
-  if (!PyArg_ParseTupleAndKeywords(args, keywds, "it#si|iO", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(args, keywds, "it#|siiO", kwlist,
                                   &fd,
                                   &iov[0].iov_base,
                                   &iov[0].iov_len,
@@ -39,20 +39,26 @@
   memset(&sa, 0, sizeof(sa));
   sa.sin_family = AF_INET;
   sa.sin_port = htons(port);
+  if (host)
   {
     int address_valid;
 
     address_valid = inet_aton(host, &sa.sin_addr);
     if (!address_valid)
       return NULL;
+
+    msg.msg_name = &sa;
+    msg.msg_namelen = sizeof(sa);
+  } else {
+    msg.msg_name = NULL;
+    msg.msg_namelen = 0;
   }
 
-  msg.msg_name = &sa;
-  msg.msg_namelen = sizeof(sa);
-
   msg.msg_iov = iov;
   msg.msg_iovlen = 1;
 
+  msg.msg_flags = 0;
+
   msg.msg_control = cmsgbuf;
   msg.msg_controllen = 0;
 
--- a/lib/eunuchs/recvmsg.c     (revision 16)
+++ b/lib/eunuchs/recvmsg.c     (working copy)
@@ -94,7 +94,9 @@
     }
   }
 
-  {
+  if (sa.sin_family == AF_INET) {
+    /* maybe this check needs to be different and we
+     * should actually check the ancillary type first? */
     PyObject *r;
     r = Py_BuildValue("s#(si)iO",
                      iov[0].iov_base, ret,
@@ -104,6 +106,15 @@
                      );
     free(iov[0].iov_base);
     return r;
+  } else {
+    PyObject *r;
+    r = Py_BuildValue("s#iO",
+                     iov[0].iov_base, ret,
+                     msg.msg_flags,
+                     ancillary
+                     );
+    free(iov[0].iov_base);
+    return r;
   }
 }
 




-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to