For the analysis, see https://bugzilla.mozilla.org/show_bug.cgi?id=1940471#c2
When OnDataAvailable is called after FinishDisconnect has called
FlushBufferedData(), but before mState was updated to mDisconnected,
then OnDataAvailable did not know that it could write the data.
Consequently, OnDataAvailable proceeded to buffer the data. If
OnDataAvailable is not called again (which flushes the buffer if
needed), then this data would be lost forever (which was caught in debug
builds as an assertion failure - see bug report).
This patch introduces a new flag to ensure that OnDataAvailable writes
data immediately instead of buffering. With this, there are now three
flags that help OnDataAvailable to short-circuit early:
- mDisconnectedByOnStartRequest (set on main thread)
- mState == State::Disconnected (set on actor thread)
- mDisconnectedByFinishDisconnect (set on IO thread - new)
Differential Revision: https://phabricator.services.mozilla.com/D244921