Re: PR_Write blocks indefinitely

Monkeon <[email protected]> Thu, 18 Dec 2008 04:05:45 -0800 (PST)
Newsgroups gmane.comp.mozilla.devel.nspr
Message-ID <[email protected]>
As requested, I obtained the following debug information:

peerAddr.inet.port=1082, selfAddr.inet.port=1081

As you can see, the ports are definitely different!!  Any ideas what could
actually cause this?  The client is running Kaspersky on their machines, so
don't know if that could be interfering.  Also, it is a Core2Duo
machine...could some sort of threading issue be to blame?


Wan-Teh Chang-3 wrote:
> 
> 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
> _______________________________________________
> dev-tech-nspr mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-tech-nspr
> 
> 

-- 
View this message in context: http://www.nabble.com/PR_Write-blocks-indefinitely-tp20130460p21071475.html
Sent from the Mozilla - NSPR mailing list archive at Nabble.com.