[netwerk] Make nsIncrementalStreamLoader's GetNumBytesRead threadsafe.

This prevents a potential race and simplifies the code a bit by keeping the
bytes read separate instead of using mData, which is modified from another
thread from OnDataAvailable.
Relaxed atomics are fine for these, since they don't guard any memory.
This commit is contained in:
Moonchild 2020-10-23 08:10:01 +00:00 committed by roytam1
commit efa2f805fe
4 changed files with 14 additions and 10 deletions

View file

@ -47,8 +47,9 @@ protected:
// available.
mozilla::Vector<uint8_t, 0> mData;
// Number of consumed bytes from the mData.
size_t mBytesConsumed;
// Number of bytes read, which may differ from the number of bytes in mData,
// since we incrementally remove from there.
mozilla::Atomic<uint32_t, mozilla::Relaxed> mBytesRead;
};
#endif // nsIncrementalStreamLoader_h__