From: Stephen D. <sd...@gm...> - 2010-04-12 14:04:18
|
On Mon, Apr 12, 2010 at 2:33 PM, Gustaf Neumann <ne...@wu...> wrote: > > Without the patch naviserver hangs (blocks) on that machine already > at the first or second request. This should never happen as the listen socket is set to non-blocking mode, here: http://bitbucket.org/naviserver/naviserver/src/tip/nssock/nssock.c#cl-131 nssock.c:Accept() calls nsd/sock.c:Ns_SockAccept() which calls accept(2), who's man page says: If no pending connections are present on the queue, and the socket is not marked as non-blocking, accept() blocks the caller until a connection is present. If the socket is marked non-blocking and no pending connections are present on the queue, accept() fails with the error EAGAIN or EWOULDBLOCK. In which case, Ns_SockAccept looks wrong: SOCKET Ns_SockAccept(SOCKET lsock, struct sockaddr *saPtr, int *lenPtr) { SOCKET sock; sock = accept(lsock, saPtr, (socklen_t *) lenPtr); if (sock != INVALID_SOCKET) { sock = SockSetup(sock); } return sock; } Shouldn't this be something more like: if (sock > -1) { sock = SockSetup(sock); } as INVALID_SOCKET is -1 but there is more than one possible error state? (I haven't tried this...) |