Open
Bug 442294
Opened 16 years ago
Updated 2 years ago
NSPR doesn't provide any mechanism for disconnecting UDP sockets
Categories
(NSPR :: NSPR, defect)
Tracking
(Not tracked)
REOPENED
People
(Reporter: alex, Unassigned)
References
Details
Attachments
(1 file)
1.09 KB,
patch
|
Details | Diff | Splinter Review |
For UDP sockets, POSIX connect() can be called to (re-)connect or disconnect the socket. The latter is done by calling connect() with a "null address". According to Stevens' Unix Network Programming (Vol 1, 3rd ed., sec. 8.11, p. 254): "The most portable solution is to zero out an address structure, set the family to AF_UNSPEC and pass it to connect." Unfortunately NSPR's PR_Connect() doesn't accept PRNetAddr structures with family PR_AF_UNSPEC - at least not the implementation in ptio.c (pt_Connect). One easy way of getting it to work for pt_Connect is to remove the assertion PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE); and change _PR_NetAddrSize() to return something like sizeof(addr->raw) instead of 0 for PR_AF_UNSPEC addresses. I'm a little unsure about the wider implications though.
Comment 1•16 years ago
|
||
We should be able to change PR_Connect() to allow this. Could you test your proposed changes? They seem good to me.
Status: NEW → ASSIGNED
Reporter | ||
Comment 2•16 years ago
|
||
I've discovered that calling PR_Connect with PR_AF_INET "0.0.0.0" (or PR_AF_INET6 "::", as appropriate for a given socket) works just as well as PR_AF_UNSPEC. I've tested this on Linux, OS X and Windows. So it looks like the changes I was proposing above aren't needed... they only worked for platforms using ptio.c anyway. Shall I close the bug as INVALID?
Comment 3•16 years ago
|
||
OK. It would still be nice if you could attach your patch to this bug report for future reference. Someone who reads Stevens' is likely to try PR_AF_UNSPEC first, so supporting that could still be useful. We could easily adapt your changes to ptio.c for platforms using prsocket.c.
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → WONTFIX
Updated•16 years ago
|
Resolution: WONTFIX → INVALID
Reporter | ||
Comment 4•16 years ago
|
||
It turns out that PR_AF_INET/PR_AF_INET6 don't work on Linux after all; the linux networking code explicitly checks for AF_UNSPEC for disconnecting sockets. My unit test didn't pick this up as I only tested the loopback interface. So it would be great if we could legalize PR_AD_UNSPEC after all. Patch coming up.
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
Reporter | ||
Comment 5•16 years ago
|
||
Proposed patch allowing a PR_AF_UNSPEC address to be passed to pt_Connect.
Updated•16 years ago
|
Attachment #332262 -
Flags: review?(wtc)
Comment 6•2 years ago
|
||
The bug assignee is inactive on Bugzilla, so the assignee is being reset.
Assignee: wtc → nobody
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•