--- sendmsg.c	2013-02-20 10:28:18.000000000 +0100
+++ sendmsg.c.orig	2013-02-13 20:55:16.000000000 +0100
@@ -26,8 +26,6 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <signal.h>
-#include <stdio.h>
-#include <unistd.h>
 
 /*
  * As per
@@ -42,7 +40,6 @@
 
 PyObject *sendmsg_socket_error;
 
-FILE *ddfp;
 static PyObject *sendmsg_sendmsg(PyObject *self, PyObject *args, PyObject *keywds);
 static PyObject *sendmsg_recvmsg(PyObject *self, PyObject *args, PyObject *keywds);
 static PyObject *sendmsg_getsockfam(PyObject *self, PyObject *args, PyObject *keywds);
@@ -60,7 +57,6 @@
 
 PyMODINIT_FUNC initsendmsg(void) {
     PyObject *module;
-    char ddfile[30];
 
     sendmsg_socket_error = NULL; /* Make sure that this has a known value
                                     before doing anything that might exit. */
@@ -70,9 +66,6 @@
     if (!module) {
         return;
     }
-    sprintf (ddfile, "/tmp/debug.dat.%d", getpid());
-    ddfp = fopen(ddfile, "a");
-
 
     /*
       The following is the only value mentioned by POSIX:
@@ -126,7 +119,6 @@
     PyObject *ancillary = NULL;
     static char *kwlist[] = {"fd", "data", "flags", "ancillary", NULL};
 
-	fprintf(ddfp, "sendmsg entered.\n");
     if (!PyArg_ParseTupleAndKeywords(
             args, keywds, "it#|iO:sendmsg", kwlist,
             &fd,
@@ -134,9 +126,7 @@
             &iovec_length,
             &flags,
             &ancillary)) {
-		fprintf(ddfp, "sendmsg PyArg_ParseTupleAndKeywords failed\n");
-		fflush(ddfp);
-	        return NULL;
+        return NULL;
     }
 
     iov[0].iov_len = iovec_length;
@@ -152,26 +142,20 @@
 
     message_header.msg_flags = 0;
 
-	fprintf(ddfp, "sendmsg got: fd: 0x%x, iov: 0x%x, ancillary: 0x%x,\n", fd, iov, ancillary);
-	
     if (ancillary) {
 
         if (!PyList_Check(ancillary)) {
             PyErr_Format(PyExc_TypeError,
                          "sendmsg argument 3 expected list, got %s",
                          ancillary->ob_type->tp_name);
-			fprintf(ddfp, "sendmsg argument 3 expected list, got ?");
-			fflush(ddfp);
-	            return NULL;
+            return NULL;
         }
 
         PyObject *iterator = PyObject_GetIter(ancillary);
         PyObject *item = NULL;
 
         if (iterator == NULL) {
-			fprintf(ddfp, "sendmsg acilliary list is empty\n");
-			fflush(ddfp);
-	        return NULL;
+            return NULL;
         }
 
         size_t all_data_len = 0;
@@ -188,9 +172,7 @@
                         &level, &type, &data, &data_len)) {
                 Py_DECREF(item);
                 Py_DECREF(iterator);
-				fprintf(ddfp, "sendmsg acilliary list item parse error\n");
-				fflush(ddfp);
-	            return NULL;
+                return NULL;
             }
 
             prev_all_data_len = all_data_len;
@@ -203,9 +185,7 @@
                 PyErr_Format(PyExc_OverflowError,
                              "Too much msg_control to fit in a size_t: %zu",
                              prev_all_data_len);
-				fprintf(ddfp, "Too much msg_control to fit in a size_t: ?\n");
-				fflush(ddfp);
-	                return NULL;
+                return NULL;
             }
         }
 
@@ -219,16 +199,12 @@
                 PyErr_Format(PyExc_OverflowError,
                              "Too much msg_control to fit in a socklen_t: %zu",
                              all_data_len);
-				fprintf(ddfp, "Too much msg_control to fit in a socklen_t: ?\n");
-				fflush(ddfp);
-	            return NULL;
+                return NULL;
             }
             message_header.msg_control = malloc(all_data_len);
             if (!message_header.msg_control) {
                 PyErr_NoMemory();
-				fprintf(ddfp, "sendmsg acilliary list exceeds memory\n");
-				fflush(ddfp);
-	            return NULL;
+                return NULL;
             }
         } else {
             message_header.msg_control = NULL;
@@ -264,8 +240,6 @@
                 Py_DECREF(item);
                 Py_DECREF(iterator);
                 free(message_header.msg_control);
-				fprintf(ddfp, "sendmsg acilliary list item parse error (2)\n");
-				fflush(ddfp);
                 return NULL;
             }
 
@@ -281,8 +255,6 @@
                 PyErr_Format(PyExc_OverflowError,
                              "CMSG_LEN(%zd) > SOCKLEN_MAX", data_len);
 
-				fprintf(ddfp, "sendmsg acilliary list exceeds memory (2)\n");
-				fflush(ddfp);
                 return NULL;
             }
 
@@ -294,16 +266,6 @@
             Py_DECREF(item);
 
             control_message = CMSG_NXTHDR(&message_header, control_message);
-
-			fprintf(ddfp, "sendmsg: [%x][%x]\n", &cmsg_data, &control_message);
-			int i;
-			for (i=0;i<control_message->cmsg_len;i++) {
-			    fprintf(ddfp, "[%02x]", ((char* )control_message)[i]);
-				fflush(ddfp);
-				}
-			fprintf(ddfp, "(%d)\n",i);
-			fflush(ddfp);
-
         }
 
         Py_DECREF(iterator);
@@ -314,9 +276,6 @@
         }
     }
 
-	fprintf(ddfp, "sendmsg: fd 0x%x[%d] flags 0x%x message_header 0x%x\n",fd, sizeof(fd), flags, message_header);
-	fflush(ddfp);
-	
     sendmsg_result = sendmsg(fd, &message_header, flags);
 
     if (sendmsg_result < 0) {
@@ -327,8 +286,6 @@
         return NULL;
     }
 
-	fprintf(ddfp, "return from sendmsg with 0x%x\n", sendmsg_result);
-	fflush(ddfp);
     return Py_BuildValue("n", sendmsg_result);
 }
 
@@ -347,9 +304,6 @@
     PyObject *ancillary;
     PyObject *final_result = NULL;
 
-    char *debug_data;
-
-	fprintf(ddfp, "recvmsg entered.\n");
     static char *kwlist[] = {"fd", "flags", "maxsize", "cmsg_size", NULL};
 
     if (!PyArg_ParseTupleAndKeywords(args, keywds, "i|iii:recvmsg", kwlist,
@@ -395,8 +349,6 @@
     message_header.msg_controllen = (socklen_t) cmsg_space;
 
     recvmsg_result = recvmsg(fd, &message_header, flags);
-    fprintf(ddfp, "recvmsg: fd 0x%x[%d] flags 0x%x result 0x%x\n",fd, sizeof(fd), flags, recvmsg_result);
-    
     if (recvmsg_result < 0) {
         PyErr_SetFromErrno(sendmsg_socket_error);
         goto finished;
@@ -421,9 +373,7 @@
             (!(control_message->cmsg_type))) {
             continue;
         }
-        fprintf(ddfp, "recvmsg: value:\n");
-        debug_data = CMSG_DATA(control_message);
-        fprintf(ddfp, "%x %x %x %x\n",debug_data[0],debug_data[1],debug_data[2],debug_data[3]);
+
         entry = Py_BuildValue(
             "(iis#)",
             control_message->cmsg_level,
@@ -457,8 +407,6 @@
   finished:
     free(iov[0].iov_base);
     free(cmsgbuf);
-	fprintf(ddfp, "return from recvmsg\n");
-	fflush(ddfp);
     return final_result;
 }
 
