Re: PR_Read fails second time on Solaris 8

Wan-Teh Chang <[email protected]> Wed, 27 May 2009 16:28:13 -0700
Newsgroups gmane.comp.mozilla.devel.nspr
Message-ID <[email protected]>
On Wed, May 27, 2009 at 3:26 PM, Vinu <[email protected]> wrote:
> Hi Nelson,
>
> Yes, I did some more tests.
>
> The server sends the data and then closes the connection(becuase we use HTTP
> Connection:close and not Keep-Alive).
>
> But shouldnt PR_Read return the entire data and then only return 0(becuase
> the connection is closed).
> How can it return 0, before all the data has been returned to the
> application.
>
> BTW this same code on Linux and Windows works fine.

I'm afraid that you'll need to debug this yourself because we
can't reproduce this problem.  The relevant file is
mozilla/nsprpub/pr/src/pthreads/ptio.c.  Look at pt_Recv and
pt_recv_cont.

The implementation of PR_Read is essentially the same between
Solaris and Linux, with one difference -- as a performance optimization,
we use read() instead of recv() on Solaris only.  See:
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/nsprpub/pr/src/pthreads/ptio.c&rev=3.113&mark=1858,1863,1865#1830
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/nsprpub/pr/src/pthreads/ptio.c&rev=3.113&mark=779,786,789#772

Please try changing those two instances of
    #if defined(SOLARIS)
to
    #if defined(SOLARIS_X)
(which disables the Solaris code), and rebuild NSPR.  Does that
make the problem go away on Solaris?

If that fixes the problem, I have to admit that I don't understand
why because read() should also work with sockets.

If that doesn't fix the problem, you can add printf statements
or use a debugger to find out what the read() or recv() calls
return, etc.

Wan-Teh