Hi,

Ok.

My problems were not with the kqreactor.py so I have not so much experience of that does but .

To concentrate on the sendfd.py problem:

[caldav-0] File "/usr/local/lib/python2.7/site-packages/Calendar_and_Contacts_Server-4.2-py2.7-freebsd-8.2-RELEASE-p9-amd64.egg/twext/python/sendfd.py", line 65, in recvfd
[caldav-0]          [unpackedFD] = unpack("i", packedFD)
[caldav-0]      struct.error: unpack requires a string argument of
length 4

What I did was to add a debug to file thing in sendmsg.c
Attached a small test patch (against current trunk).
Patch it, then you need to compile the sendmsg.c module :

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python2.7 -c sendmsg.c -o sendmsg.o


gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,relro -Wl,-z,relro -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 sendmsg.o -o sendmsg.so

or build whole calendar server.

Then run the test

trial test/test_sendmsg.py

In ls /tmp/debug.dat.PID should be the output..
In my case :
recvmsg: fd [8] [0] result [d]

Now, you can adapt the things to track your problem and start
a real calendar server, at the crash there should be several pid files..
maybe you get some data out of them..

/Fred



On 02/13/2013 12:05 AM, Axel Rau wrote:
I did not make any progress. I tried
- in sendmsg_sendmsg to check for the right type arg (with PyErr_Format, got no 
error)
- to print out the args with PySys_WriteStdout (did not get anything)
- I'm not even sure, if this error is related to my problem:
     test_sendSubProcessFD ...                         [ERROR]
- If I try control_message->cmsg_type = 0;, I get Errno 22 in sendfd, as 
expected

I need more pointers...

Axel

Am 08.02.2013 um 13:30 schrieb Fredrik Unger:

Hi,

I found some problem with sendfd.c some time ago. [1]

My problem was with 64 bit Debian and twext/python/sendmsg.c

Have a look and see if there is anything that is FreeBSD non friendly there.

You can try with the tests :
cd twext/python
trial test/test_sendmsg.py
That could be easier to debug than the full code.

On my setup I failed test_sendSubProcessFD now, but I just did a quick test. 
Sources are not up to date or anything..

You can also add some printouts to the C code, and see if you find something 
bad.

It is most probably some flags or so that might not be covered for BSD ?
and sendmsg.c is the interface to the operating system from python..

Just some suggestions. If you need more pointers let me know, but I have no 
experience with FreeBSD..

/Fred

[1] 
https://lists.macosforge.org/pipermail/calendarserver-users/2012-August/002032.html

On 02/08/2013 01:04 PM, Axel Rau wrote:

Am 02.02.2013 um 17:39 schrieb Axel Rau:

[caldav-0]        File 
"/usr/local/lib/python2.7/site-packages/Calendar_and_Contacts_Server-4.2-py2.7-freebsd-8.2-RELEASE-p9-amd64.egg/twext/python/sendfd.py",
 line 65, in recvfd
[caldav-0]          [unpackedFD] = unpack("i", packedFD)
[caldav-0]      struct.error: unpack requires a string argument of length 4
This is hard to debug. I did not make much progress.
If I switch to kqueue-reactor, I'm getting another FD problem when starting 
listening:
---
Log opened.
twistd 12.1.0 (/usr/local/bin/python2.7 2.7.3) starting up.
reactor class: twext.internet.kqreactor.KQueueReactor.
ControlSocket starting on '/var/db/caldavd/caldavd.sock'
Traceback (most recent call last):
   File "/usr/local/bin/twistd", line 14, in<module>
     run()
   File "/usr/local/lib/python2.7/site-packages/twisted/scripts/twistd.py", 
line 27, in run
     app.run(runApp, ServerOptions)
   File "/usr/local/lib/python2.7/site-packages/twisted/application/app.py", 
line 652, in run
     runApp(config)
   File "/usr/local/lib/python2.7/site-packages/twisted/scripts/twistd.py", 
line 23, in runApp
     _SomeApplicationRunner(config).run()
   File "/usr/local/lib/python2.7/site-packages/twisted/application/app.py", 
line 390, in run
     self.postApplication()
   File 
"/usr/local/lib/python2.7/site-packages/twisted/scripts/_twistd_unix.py", line 
230, in postApplication
     self.startApplication(self.application)
   File 
"/usr/local/lib/python2.7/site-packages/twisted/scripts/_twistd_unix.py", line 
340, in startApplication
     service.IService(application).privilegedStartService()
   File 
"/usr/local/lib/python2.7/site-packages/twisted/application/service.py", line 
277, in privilegedStartService
     service.privilegedStartService()
   File 
"/usr/local/lib/python2.7/site-packages/twisted/application/service.py", line 
277, in privilegedStartService
     service.privilegedStartService()
   File 
"/usr/local/lib/python2.7/site-packages/Calendar_and_Contacts_Server-4.2-py2.7-freebsd-9.1-RELEASE-amd64.egg/calendarserver/tap/caldav.py",
 line 487, in privilegedStartService
     super(GroupOwnedUNIXServer, self).privilegedStartService()
   File 
"/usr/local/lib/python2.7/site-packages/twisted/application/internet.py", line 
105, in privilegedStartService
     self._port = self._getPort()
   File 
"/usr/local/lib/python2.7/site-packages/twisted/application/internet.py", line 
133, in _getPort
     'listen%s' % (self.method,))(*self.args, **self.kwargs)
   File "/usr/local/lib/python2.7/site-packages/twisted/internet/posixbase.py", 
line 406, in listenUNIX
     p.startListening()
   File "/usr/local/lib/python2.7/site-packages/twisted/internet/unix.py", line 
303, in startListening
     self.startReading()
   File "/usr/local/lib/python2.7/site-packages/twisted/internet/abstract.py", 
line 416, in startReading
     self.reactor.addReader(self)
   File 
"/usr/local/lib/python2.7/site-packages/Calendar_and_Contacts_Server-4.2-py2.7-freebsd-9.1-RELEASE-amd64.egg/twext/internet/kqreactor.py",
 line 84, in addReader
     self._updateRegistration(fd, KQ_FILTER_READ, KQ_EV_ADD|KQ_EV_ENABLE)
   File 
"/usr/local/lib/python2.7/site-packages/Calendar_and_Contacts_Server-4.2-py2.7-freebsd-9.1-RELEASE-amd64.egg/twext/internet/kqreactor.py",
 line 74, in _updateRegistration
     self._kq.control([ev], 0, 0)
OSError: [Errno 9] Bad file descriptor
---
Any help appreciated,
Axel
---
PGP-Key:29E99DD6  ☀ +49 151 2300 9283  ☀ computing @ chaos claudius

_______________________________________________
calendarserver-dev mailing list
calendarserver-dev@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/calendarserver-dev

_______________________________________________
calendarserver-dev mailing list
calendarserver-dev@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/calendarserver-dev

---
PGP-Key:29E99DD6  ☀ +49 151 2300 9283  ☀ computing @ chaos claudius

_______________________________________________
calendarserver-dev mailing list
calendarserver-dev@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/calendarserver-dev

Index: test/test_sendmsg.py
===================================================================
--- test/test_sendmsg.py	(revision 10711)
+++ test/test_sendmsg.py	(working copy)
@@ -25,8 +25,8 @@
 from twisted.internet.defer import inlineCallbacks
 from twisted.internet import reactor
 
-from twext.python.sendmsg import sendmsg, recvmsg
-from twext.python.sendfd import sendfd
+from sendmsg import sendmsg, recvmsg
+from sendfd import sendfd
 from twisted.internet.protocol import ProcessProtocol
 
 class ExitedWithStderr(Exception):
Index: sendmsg.c
===================================================================
--- sendmsg.c	(revision 10711)
+++ 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
@@ -40,6 +42,7 @@
 
 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);
@@ -66,7 +69,11 @@
     if (!module) {
         return;
     }
+    char ddfile[30];
+    sprintf (ddfile, "/tmp/debug.dat.%d", getpid());
+    ddfp = fopen(ddfile, "w");
 
+
     /*
       The following is the only value mentioned by POSIX:
       http://www.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html
@@ -349,6 +356,8 @@
     message_header.msg_controllen = (socklen_t) cmsg_space;
 
     recvmsg_result = recvmsg(fd, &message_header, flags);
+    fprintf(ddfp, "recvmsg: fd [%d] [%x] result [%x]\n",fd, flags, recvmsg_result);
+    
     if (recvmsg_result < 0) {
         PyErr_SetFromErrno(sendmsg_socket_error);
         goto finished;
@@ -373,7 +382,10 @@
             (!(control_message->cmsg_type))) {
             continue;
         }
-
+        char *data;
+        fprintf(ddfp, "recvmsg: value:\n");
+        data = CMSG_DATA(control_message);
+        fprintf(ddfp, "%x %x %x %x\n",data[0],data[1],data[2],data[3]);
         entry = Py_BuildValue(
             "(iis#)",
             control_message->cmsg_level,
_______________________________________________
calendarserver-dev mailing list
calendarserver-dev@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/calendarserver-dev

Reply via email to