Re: PR_Write blocks indefinitely
Wan-Teh Chang <[email protected]> Mon, 24 Nov 2008 15:03:48 -0800
| Newsgroups | gmane.comp.mozilla.devel.nspr |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Nov 24, 2008 at 3:01 PM, Wan-Teh Chang <[email protected]> wrote: > 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); You could be using another implementation of PR_NewTCPSocket at http://mxr.mozilla.org/nspr/source/nsprpub/pr/src/io/prsocket.c#1470: 1470 osfd[1] = accept(listenSock, (struct sockaddr *) &peerAddr, &addrLen); 1471 if (osfd[1] == INVALID_SOCKET) { 1472 goto failed; 1473 } 1474 if (peerAddr.sin_port != selfAddr.sin_port) { 1475 /* the connection we accepted is not from osfd[0] */ 1476 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0); 1477 goto failed; 1478 } If you're not sure which implementation you're using, please add the printf statement to both places. Wan-Teh