Closed Bug 1531708 Opened 5 years ago Closed 4 years ago

nsSyncStreamListener drops error status when waiting for data

Categories

(Core :: Networking, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla73
Tracking Status
firefox73 --- fixed

People

(Reporter: neil, Assigned: CuveeHsu)

Details

(Whiteboard: [necko-triaged])

Attachments

(1 file)

This bug seems to have been present in nsSyncStreamListener since it was originally added by bug 192284.

https://searchfox.org/mozilla-central/source/netwerk/base/nsSyncStreamListener.cpp#117

mStatus is set as the result of an OnStopRequest call. If this happens before the call to Available, then the status is returned as expected. If however Available starts waiting for data, it overwrites the status with the return value from WaitForData, which is usually NS_OK.

My guess as to the easiest way to fix this is to make WaitForData return mStatus on success.

Junior, could you take a look at this?

Assignee: nobody → juhsu
Priority: -- → P2
Whiteboard: [necko-triaged]
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

Hello neil,
Sorry for missing this.

Did you worry about this sequence?
listener->OnStopRequest() -> mStatus is set by parameter
then listener->Available() -> mStatus is set to NS_OK

However IMO mStatus won't change by Available in this case since we bailed out for failure
https://searchfox.org/mozilla-central/rev/201450283cddc9e409cec707acb65ba6cf6037b1/netwerk/base/nsSyncStreamListener.cpp#116

And nSyncStreamListener is single thread object. No race condition happened.

Flags: needinfo?(neil)
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → INVALID

(In reply to Junior from comment #2)

Hello neil,
Sorry for missing this.

Sorry for overlooking your response!

Did you worry about this sequence?
listener->OnStopRequest() -> mStatus is set by parameter
then listener->Available() -> mStatus is set to NS_OK

However IMO mStatus won't change by Available in this case since we bailed out for failure
https://searchfox.org/mozilla-central/rev/201450283cddc9e409cec707acb65ba6cf6037b1/netwerk/base/nsSyncStreamListener.cpp#116

And nSyncStreamListener is single thread object. No race condition happened.

WaitForData() calls SpinEventLoopUntil, which means that an event can call listener->OnStopRequest() after the check for failure but before listener->Available() sets mStatus back to NS_OK.

Status: RESOLVED → REOPENED
Flags: needinfo?(neil)
Resolution: INVALID → ---
Pushed by juhsu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/6b3d6a63e8c4
avoid hiding error in nsSyncStreamListener r=michal
Status: REOPENED → RESOLVED
Closed: 5 years ago4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla73
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: