PR_Recv blocks a non-blocking socket on Windows CE

RESOLVED WONTFIX

Status

NSPR
NSPR
RESOLVED WONTFIX
8 years ago
7 years ago

People

(Reporter: alexp, Assigned: Wan-Teh Chang)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

8 years ago
PR_Recv called on a non-blocking socket is supposed to return with PR_WOULD_BLOCK_ERROR if no incoming data is available at the socket.
But on Windows CE it waits for data blocking the caller.
(Reporter)

Updated

8 years ago
Assignee: wtc → alexp
Status: NEW → ASSIGNED
(Reporter)

Comment 1

8 years ago
Created attachment 432921 [details] [diff] [review]
Fix

We use w95sock.c implementation for Windows CE, which didn't do anything to make a socket non-blocking as Win95 does not support that. WinCE on the other hand supports ioctlsocket(), which could be used.
Attachment #432921 - Flags: superreview?(wtc)
Attachment #432921 - Flags: review?(bugmail)
Attachment #432921 - Flags: review?(bugmail) → review+
(Assignee)

Comment 2

8 years ago
Alex, your comment 1 is inaccurate because Win95 supports ioctlsocket.
We call ioctlsocket in _PR_MD_SOCKET, when we create a socket:
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/nsprpub/pr/src/md/windows/w95sock.c&rev=3.17&mark=147,163#146

_MD_MakeNonblock is a no-op as a performance optimization because
a socket returned by accept() inherits the non-blocking mode from
the listening socket.  Perhaps that property is not inherited on
Windows CE, which is why you need this patch?
(Reporter)

Comment 3

8 years ago
(In reply to comment #2)
> Alex, your comment 1 is inaccurate because Win95 supports ioctlsocket.

You're right. I referred to the wrong section of MSDN.

> _MD_MakeNonblock is a no-op as a performance optimization because
> a socket returned by accept() inherits the non-blocking mode from
> the listening socket.  Perhaps that property is not inherited on
> Windows CE, which is why you need this patch?

That's probably the case. PR_Accept works as it should in the nonblock test, but the PR_Recv call on the socket returned by the accept fails.

Anyway, the patch seems to fix the problem on WinCE.
Do you have any suggestions on a better fix?
(Assignee)

Comment 4

8 years ago
Comment on attachment 432921 [details] [diff] [review]
Fix

r=wtc.

I just wanted to make sure we know what the problem is.

Please add a comment to this function to note that why _MD_MakeNonblock
can do nothing for non-WINCE.  Thanks.
Attachment #432921 - Flags: superreview?(wtc) → superreview+
(Reporter)

Comment 5

8 years ago
Created attachment 432936 [details] [diff] [review]
Fix with a comment added
Attachment #432921 - Attachment is obsolete: true
Attachment #432936 - Flags: review+
(Reporter)

Updated

8 years ago
Assignee: alexp → wtc
(Reporter)

Updated

7 years ago
Status: ASSIGNED → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.