Re: PR_Write blocks indefinitely

Wan-Teh Chang <[email protected]> Mon, 24 Nov 2008 15:01:18 -0800
Newsgroups gmane.comp.mozilla.devel.nspr
Message-ID <[email protected]>
On Mon, Nov 24, 2008 at 8:01 AM, Monkeon <[email protected]> wrote:
>
> The platform is Windows XP and PR_GetOSError() returns 0.

Thanks for the info.  I think we're failing here in PR_NewTCPSocketPair:
http://mxr.mozilla.org/nspr/source/nsprpub/pr/src/io/prsocket.c#1572

1572     f[1] = PR_Accept(listenSock, &peerAddr, PR_INTERVAL_NO_TIMEOUT);
1573     if (f[1] == NULL) {
1574         goto failed;
1575     }
1576     if (peerAddr.inet.port != selfAddr.inet.port) {
1577         /* the connection we accepted is not from f[0] */
1578         PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);  <== HERE
1579         goto failed;
1580     }

This is a strange problem.  The check on line 1576 is to verify that
we have accepted a connection from ourselves.  If the check fails, it
means for some other process may have connected to our listening
socket, and so this function should fail.

Could you add a printf statement above the PR_SetError call to
print both ntohs(peerAddr.inet.port) and ntohs(selfAddr.inet.port)?

    printf("peerAddr.inet.port=%d, selfAddr.inet.port=%d\n",
            ntohs(peerAddr.inet.port), ntohs(selfAddr.inet.port));
    fflush(stdout);

Wan-Teh