On Mon, Apr 12, 2010 at 2:33 PM, Gustaf Neumann <neum...@wu-wien.ac.at> 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...)

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel

Reply via email to