Open Bug 711786 Opened 13 years ago Updated 4 years ago

nsISocketTransport::IsAlive is documented as being thread safe, but nsSocketTransport2::IsAlive() is not thread-safe

Categories

(Core :: Networking, defect, P5)

defect

Tracking

()

People

(Reporter: briansmith, Unassigned)

References

Details

(Whiteboard: [necko-backlog])

The IDL for nsISocketTransport has this comment:

"* NOTE: This is a free-threaded interface, meaning that the methods on
 * this interface may be called from any thread."

However, the IsAlive() methods calls PR_Recv, and calling PR_Recv (at least on an SSL socket) is NOT thread-safe. (See bug 427948, at least.)

I think we should enforce that IsAlive is only called on the socket transport thread, and change the documentation of nsISocketTransport.
For a quick fix of bug 711786 I think we could just search for the TCP NSPR layer of the socket to call PR_Recv on it.  Maybe do that only off the main thread.
(In reply to Honza Bambas (:mayhemer) from comment #1)
> off the main thread.

Should be: off the socket thread, of course.
(In reply to Honza Bambas (:mayhemer) from comment #1)
> For a quick fix of bug 711786 I think we could just search for the TCP NSPR
> layer of the socket to call PR_Recv on it.  Maybe do that only off the main
> thread.

I'll make an attempt at this right now. no guarantees :)
(In reply to Patrick McManus [:mcmanus] from comment #3)

> 
> I'll make an attempt at this right now. no guarantees :)

honza says in IM he's got it.
(In reply to Patrick McManus [:mcmanus] from comment #4)
> (In reply to Patrick McManus [:mcmanus] from comment #3)
> 
> > 
> > I'll make an attempt at this right now. no guarantees :)
> 
> honza says in IM he's got it.

I assume this comment was related to https://bug711787.bugzilla.mozilla.org/attachment.cgi?id=582828

Any reason to not request review on this?

FYI, we are running into this bug for the IRC code that's used for both Instantbird and Thunderbird (It's been reported in https://bug711787.bugzilla.mozilla.org/attachment.cgi?id=582828).
Blocks: Instantbird
See Also: → 827264
Whiteboard: [necko-backlog]
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: -- → P1
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: P1 → P3

Bulk-downgrade of unassigned, untouched DOM/Storage bug's priority.

If you have reason to believe, this is wrong, please write a comment and ni :jstutte.

Severity: critical → S4
Priority: P3 → P5
You need to log in before you can comment on or make changes to this bug.