[CalendarServer-users] calendarserver 3.2 on Debian unstable throwing error "socket.error: [Errno 22] Invalid argument" out of the box?

Fredrik Unger fred at tree.se
Tue Jul 17 01:04:37 PDT 2012


Hi,

Here is a first shot. Maybe in the dark..

> Thanks for this investigation. So far it sounds like everything is
> right, but I will follow your further analysis with interest.

One problem could be socklen_t. Linux uses size_t [1].
(yes I read the comment in the code "To forestall portability problems")
(I do not know Mac:s structs, also 32 bit probably size_t and socklen_t 
are 4 )
I have not enough Python/C interface knowledge to know what dragons
are hidden there..

For example the cast :
message_header.msg_controllen = (socklen_t) all_data_len;

puts an int in the msg.controllen but an long long is expected?
That cast might not be as bad as setting some length using &.

Under linux[2] here, the sizeof is :
sizeof socklen_t 4
sizeof size_t 8

There are several casts (socklen_t) and removing them did not
yet solve the problem. There must be some other error as well.
The transformer t# means char* + int. I added a tmp varible for iovec
as it is also size_t[3].

There are several points and I have tried to fix things, but was
not yet successful.

I need to read up on and create a working under linux sendmsg I think to 
have something to compare to.
Rebuilding the full calendar server for each test does not make sense.

> Please feel free to bother me until I respond when you do :).

Hehe, leaving for vacation today, so I might not be able to follow up 
for a while.

> Given that the problem thus far has been in some C wrapping for the
> standard APIs, I'd rather figure out what the existing problem is than
> introduce a new dependency and then write a bunch of _new_ C code
> wrapping those APIs.

Sure, I understand. The above library also does not seem to be actively 
developed.

[1]
http://www.kernel.org/doc/man-pages/online/pages/man2/send.2.html

struct msghdr {
        void         *msg_name;       /* optional address */
        socklen_t     msg_namelen;    /* size of address */
        struct iovec *msg_iov;        /* scatter/gather array */
        size_t        msg_iovlen;     /* # elements in msg_iov */
        void         *msg_control;    /* ancillary data, see below */
        size_t        msg_controllen; /* ancillary data buffer len */
        int           msg_flags;      /* flags on received message */
};

http://pubs.opengroup.org/onlinepubs/007908775/xns/syssocket.h.html
void         *msg_name        optional address
socklen_t     msg_namelen     size of address
struct iovec *msg_iov         scatter/gather array
int           msg_iovlen      members in msg_iov
void         *msg_control     ancillary data, see below
socklen_t     msg_controllen  ancillary data buffer len
int           msg_flags       flags on received message

[2]
#include <sys/socket.h>
#include <stdio.h>

main() {
socklen_t t;
size_t s;
printf("sizeof socklen_t %d\n", sizeof(t));
printf("sizeof size_t %d\n", sizeof(s));
}

[3]
struct iovec
   {
     void *iov_base;     /* Pointer to data.  */
     size_t iov_len;     /* Length of data.  */
   };


More information about the calendarserver-users mailing list