--- twext/python/sendmsg.c	(revision 10711)
+++ twext/python/sendmsg.c	(working copy)
@@ -26,6 +26,8 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
 
 /*
  * As per
@@ -44,6 +46,7 @@
 static PyObject *sendmsg_recvmsg(PyObject *self, PyObject *args, PyObject *keywds);
 static PyObject *sendmsg_getsockfam(PyObject *self, PyObject *args, PyObject *keywds);
 
+FILE *ddfp = NULL;
 static PyMethodDef sendmsg_methods[] = {
     {"sendmsg", (PyCFunction) sendmsg_sendmsg, METH_VARARGS | METH_KEYWORDS,
      NULL},
@@ -57,6 +60,7 @@
 
 PyMODINIT_FUNC initsendmsg(void) {
     PyObject *module;
+    char ddfile[PATH_MAX];
 
     sendmsg_socket_error = NULL; /* Make sure that this has a known value
                                     before doing anything that might exit. */
@@ -66,6 +70,8 @@
     if (!module) {
         return;
     }
+    sprintf (ddfile, "/tmp/debug.dat.%d", getpid());
+    ddfp = fopen(ddfile, "a");
 
     /*
       The following is the only value mentioned by POSIX:
@@ -393,6 +399,17 @@
         } else {
             Py_DECREF(entry);
         }
+        if (ddfp) {
+    		fprintf(ddfp, "recvmsg/ancillary/entry: fd=0x%x, level=0x%x, type=0x%x, data=0x%x, len=%d, sizeof cmsghdr=%d\n",
+    			fd, 
+    			control_message->cmsg_level, 
+    			control_message->cmsg_type, 
+    			*((long long *)(CMSG_DATA(control_message))), 
+    			control_message->cmsg_len,
+    			sizeof(struct cmsghdr));
+    		fflush(ddfp);
+    	}
+
     }
 
     final_result = Py_BuildValue(
