Commit Graph
201 Commits
Author SHA1 Message Date
Daniel Holbert b3b4ede596 Bug 2043789: Use MakeRefPtr to do allocation for various RefPtr variables in xpcom/{io,ioutils}/. r=xpcom-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D303598
2026-05-30 17:24:07 +00:00
agoloman 445c467866 Revert "Bug 2043790: Use MakeRefPtr to do allocation for various RefPtr variables in xpcom/tests/. r=xpcom-reviewers,emilio" for causing build bustages @TestNonBlockingAsyncInputStream.cpp.
This reverts commit ed098a6dfc.

Revert "Bug 2043789: Use MakeRefPtr to do allocation for various RefPtr variables in xpcom/{io,ioutils}/. r=xpcom-reviewers,emilio"

This reverts commit aa8e617fd8.

Revert "Bug 2043788: Use MakeRefPtr to do allocation for various RefPtr variables in xpcom/{base,ds}/. r=xpcom-reviewers,emilio"

This reverts commit 4f52fb1147.
2026-05-30 17:00:34 +00:00
Daniel Holbert aa8e617fd8 Bug 2043789: Use MakeRefPtr to do allocation for various RefPtr variables in xpcom/{io,ioutils}/. r=xpcom-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D303598
2026-05-30 15:26:23 +00:00
Josh Aas b9b03e4d7b Bug 2029525 - Fix read state after backwards seek in nsMultiplexInputStream. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D292103
2026-04-07 18:13:23 +00:00
Sylvestre Ledru 6149f49299 Bug 2023419 - Remove Emacs/Vim modelines from xpcom/ r=emilio
replaced by .editorconfig
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D287878
2026-03-16 17:22:07 +00:00
serge-sans-paille fbcd1f12c6 Bug 2011222 - Remove usage of DeprecatedAbs in xpcom/io/nsMultiplexInputStream.cpp r=emilio,xpcom-reviewers
Current implementation of nsMultiplexInputStream::Seek had a potential
integer overflow on the initialization of `streamLength`.

Differential Revision: https://phabricator.services.mozilla.com/D279527
2026-01-20 06:54:18 +00:00
Sandor Molnar ab02d4aae0 Revert "Bug 2011222 - Remove usage of DeprecatedAbs in xpcom/io/nsMultiplexInputStream.cpp r=emilio,xpcom-reviewers" for causing build bustages @ nsMultiplexInputStream.cpp
This reverts commit 9b3cf55d3d.
2026-01-19 22:13:45 +00:00
serge-sans-paille 9b3cf55d3d Bug 2011222 - Remove usage of DeprecatedAbs in xpcom/io/nsMultiplexInputStream.cpp r=emilio,xpcom-reviewers
Current implementation of nsMultiplexInputStream::Seek had a potential
integer overflow on the initialization of `streamLength`.

Differential Revision: https://phabricator.services.mozilla.com/D279527
2026-01-19 21:02:51 +00:00
Norisz Fay 579352f8ec Revert "Bug 2011222 - Remove usage of DeprecatedAbs in xpcom/io/nsMultiplexInputStream.cpp r=emilio,xpcom-reviewers" for causing nsMultiplexInputStream.cpp related failures
This reverts commit 8b1b41ddc3.
2026-01-19 16:15:22 +00:00
serge-sans-paille 8b1b41ddc3 Bug 2011222 - Remove usage of DeprecatedAbs in xpcom/io/nsMultiplexInputStream.cpp r=emilio,xpcom-reviewers
Current implementation of nsMultiplexInputStream::Seek had a potential
integer overflow on the initialization of `streamLength`.

Differential Revision: https://phabricator.services.mozilla.com/D279527
2026-01-19 15:18:13 +00:00
serge-sans-paille c961fa4a0b Bug 1993127 - Remove unused inclusion of Attributes.h from xpcom/* r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D269714
2025-10-24 09:33:39 +00:00
Narcis Beleuzu 9884ff2637 Revert "Bug 1993171 - Cleanup mfbt/MathAlgorithms.h r=emilio,win-reviewers,layout-reviewers,gstoll" for bustages on TestJSHandleRootedTypedef
This reverts commit 7fef278653.
2025-10-22 09:05:40 +00:00
serge-sans-paille 7fef278653 Bug 1993171 - Cleanup mfbt/MathAlgorithms.h r=emilio,win-reviewers,layout-reviewers,gstoll
- Remove DeprecatedAbs, replacing its usage by Abs or std::abs + explicit
  MOZ_ASSERT where it makes sense

- Use std::numeric_limits<...> instead of equivalent C headers

Differential Revision: https://phabricator.services.mozilla.com/D267914
2025-10-22 08:54:46 +00:00
Serban Stanca 04f2aead1f Revert "Bug 1993171 - Cleanup mfbt/MathAlgorithms.h r=emilio,win-reviewers,layout-reviewers,gstoll" for causing spidermonkey bustages in TestCeilingFloor.cpp.
This reverts commit aad24563c3.
2025-10-08 16:59:09 +00:00
serge-sans-paille aad24563c3 Bug 1993171 - Cleanup mfbt/MathAlgorithms.h r=emilio,win-reviewers,layout-reviewers,gstoll
- Remove DeprecatedAbs, replacing its usage by std::abs + explicit
  MOZ_ASSERT where it makes sens

- Use std::numeric_limits<...> instead of equivalent C headers

Differential Revision: https://phabricator.services.mozilla.com/D267914
2025-10-08 16:18:22 +00:00
Jeff Muizelaar 9bdb6c8b27 Bug 1942380 - Use nsMultiplexInputStream directly from C++. r=valentin,necko-reviewers
This avoids having to go through the XPCOM abstract class which
removes some unneeded code.

We need to move class definition of nsMultiplexInputStream to make
this possible.

Differential Revision: https://phabricator.services.mozilla.com/D234732
2025-02-10 21:09:50 +00:00
Nika Layzell 2e6ea183a0 Bug 1818305 - Part 2: Add a streamStatus method to nsIInputStream, r=xpcom-reviewers,necko-reviewers,geckoview-reviewers,valentin,jesup,m_kato,mccr8
This is semantically similar to the existing available() method, however will
not block, and doesn't need to do the work to actually determine the number of
available bytes.

As part of this patch, I also fixed one available() implementation which was
incorrectly throwing NS_BASE_STREAM_WOULD_BLOCK.

Differential Revision: https://phabricator.services.mozilla.com/D170697
2023-03-15 19:52:34 +00:00
Nika Layzell 859529ed91 Bug 1782181 - Part 2: Notify nsMultiplexInputStream callbacks if AsyncWait fails, r=asuth
When `nsMultiplexInputStream` calls `AsyncWait` from within
`OnInputStreamReady`, it is possible for those calls to fail. In that case, we
will fail to notify AsyncWait listeners, which could lead to leaks or stream
hangs. This patch changes the error handling in this situation to instead fire
a pending stream callback after an error when re-dispatching `AsyncWait`.

Depends on D153628

Differential Revision: https://phabricator.services.mozilla.com/D153629
2022-08-03 19:36:29 +00:00
Nika Layzell 183204e96f Bug 1782181 - Part 1: Support canceling AsyncWait in nsMultiplexInputStream, r=asuth
Previously nsMultiplexInputStream would not call `AsyncWait` again when the
callback was cleared, meaning that the underlying wait wouldn't actually be
cancelled. This patch changes the behaviour to more consistently forward the
cancelling call to the underlying stream.

There are still some cases where the call will not be cancelled if a read or
other event caused the stream cursor to advance before canceling, however those
should generally be uncommon.

Differential Revision: https://phabricator.services.mozilla.com/D153628
2022-08-03 19:36:29 +00:00
Fabrice Desré e29be44cb7 Bug 1761040 - Prefix thread safety macros with MOZ_ r=geckoview-reviewers,media-playback-reviewers,alwu,jesup,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152575
2022-08-03 16:39:41 +00:00
Andreea Pavel fc724b92fc Backed out changeset b9d2965591b9 (bug 1761040) for landing with wrong author CLOSED TREE DONTBUILD 2022-08-03 18:55:00 +03:00
Andreea Pavel eda47f3911 Bug 1761040 - Prefix thread safety macros with MOZ_ r=geckoview-reviewers,media-playback-reviewers,alwu,jesup,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152575
2022-08-03 15:27:43 +00:00
Andreea Pavel c2e97d2e06 Backed out changeset a907159a482f (bug 1761040) for causing build bustages on a CLOSED TREE 2022-08-02 04:59:08 +03:00
Fabrice Desré d2d02e8493 Bug 1761040 - Prefix thread safety macros with MOZ_ r=geckoview-reviewers,media-playback-reviewers,alwu,jesup,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152575
2022-08-02 00:49:41 +00:00
Nika Layzell 110cae7448 Bug 1780054 - Part 2: Double-check notified stream in nsMultiplexInputStream, r=asuth
Previously, we could end up in situations where nsMultiplexInputStream
would receive a callback for a previously notified stream after it had
already advanced to the next stream due to the async nature of
notifications. This could cause us to skip a stream accidentally. This
changes the logic to re-call AsyncWait in that situation on the correct
stream rather than skipping streams.

Differential Revision: https://phabricator.services.mozilla.com/D152930
2022-07-28 15:01:49 +00:00
Andrew McCreight 9ebb07c91b Bug 1514936, part 2 - Drop the outer arguments from static components. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D146457
2022-05-17 20:24:19 +00:00
Nika Layzell edac714b84 Bug 1754004 - Part 14: Fix potential skipping of async streams in nsMultiplexInputStream, r=asuth
Before this change, we could run into issues when an async stream
accepts new data and queues a runnable to notify the stream listener,
but before that stream listener's runnable is run, the target thread
reads data from the async stream, emptying it of any available data.
This would mean that the stream appears empty in
nsMultiplexInputStream::OnInputStreamReady, and the rest of the stream
is skipped.

This patch changes the logic in OnInputStreamReady to re-call AsyncWait
in those situations and avoid skipping over the empty stream, preventing
data loss.

This situation came up when running some HTTP tests under rr with the
socket process enabled, as the upload stream can both be read due to an
OnInputStreamReady callback and due to other calls in the HTTP
machinery, leading to this potential race. With the socket process
enabled, it is possible for the upload stream to be an async pipe, which
doesn't happen in the parent process due to stream normalization.

This change makes an assumption about the behaviour of streams
implementing `nsIAsyncInputStream` which I believe is correct right now,
and has been documented. I originally had other patches which modified
`Available()`'s definition to add an extra outparameter or added extra
methods, but this seemed much simpler and accurate based on my memory of
having read the Available() implementations for async streams in-tree.

A gtest was added for the failing situation using both nsPipe and DataPipe.

Differential Revision: https://phabricator.services.mozilla.com/D144451
2022-05-13 14:16:14 +00:00
Nika Layzell 3b6702b10f Bug 1754004 - Part 11: Simplify the IPCStream serialization API, r=asuth,necko-reviewers,kershaw
As serializing IPCStream no longer requires a manager or FileDescriptor array,
the arguments are no longer necessary, and can be removed. The AutoIPCStream
helper can also be removed, as managed actors are no longer used for
serialization, so a delayed start callback is not necessary.

The delayed start parameter is also removed from nsIIPCSerializableInputStream
instances, but is still present as `aAllowLazy` on the toplevel serialization
methods.

Differential Revision: https://phabricator.services.mozilla.com/D141048
2022-05-13 14:16:13 +00:00
Nika Layzell 7a52bd0d1b Bug 1759572 - AsyncLengthWaitHelper should be threadsafe, r=asuth
This works only because the only implementation of nsIAsyncInputStreamLength
happened to only run on the current thread. Bug 1754004, changes this, and requires the reference to be threadsafe.

Differential Revision: https://phabricator.services.mozilla.com/D141037
2022-05-13 14:16:08 +00:00
Nika Layzell 14a97bf8b4 Bug 1759563 - Add SerializedComplexity to limit the complexity of serialized IPCStream instances, r=asuth,necko-reviewers,dragana
This will improve the efficiency of serializing large data pipes, which in bad
cases can end up serializing very small amounts of data in individual pipes
over IPC, and acts as a compliment to the existing logic for limiting
serialized message sizes. It is also necessary for the changes in bug 1754004,
which require the ability to include FileDescriptor inline in the message,
which could blow out our FileDescriptor count limits if pipe creation was
unlimited.

In some tests, this change reduces the number of pipes required to serialize a
nsIInputStream from over 5000 to 1.

Differential Revision: https://phabricator.services.mozilla.com/D141036
2022-05-13 14:16:08 +00:00
Nika Layzell d3639aff7b Bug 1754031 - AsyncWait implementations should support updating flags on an existing listener, r=asuth,necko-reviewers,dragana
This operation is often performed by nsAStreamCopier when switching
between the source and sink streams, in order to enable or disable the
WAIT_CLOSURE_ONLY flag. Failing to reset the wait flags can lead to a
NS_AsyncCopy hanging until the source or sink are closed when is
alternating between waiting on input and output streams. This patch
relaxes the incorrect checks on various input streams.

Differential Revision: https://phabricator.services.mozilla.com/D141034
2022-05-13 14:16:07 +00:00
Noemi Erli d4d5b7703c Backed out 22 changesets (bug 1696894, bug 1759569, bug 1754031, bug 1759563, bug 1759572, bug 1754004) for causing leack failures CLOSED TREE
Backed out changeset 673ecd5337e1 (bug 1754004)
Backed out changeset ecbf5f3c51de (bug 1754004)
Backed out changeset fc6c39f56d21 (bug 1754004)
Backed out changeset 5b3d58fbaf9d (bug 1696894)
Backed out changeset 2e56c89cf55d (bug 1754004)
Backed out changeset b7723490f025 (bug 1754004)
Backed out changeset 1dfbf61ff5dd (bug 1754004)
Backed out changeset e73abb071bb3 (bug 1754004)
Backed out changeset f9abe4fbf501 (bug 1754004)
Backed out changeset ee7aeb631cd9 (bug 1754004)
Backed out changeset d66aacfcf983 (bug 1754004)
Backed out changeset 5c2872ad6912 (bug 1754004)
Backed out changeset e1ae48f30d2c (bug 1754004)
Backed out changeset 849b63707d7f (bug 1754004)
Backed out changeset 36563e3b1e04 (bug 1754004)
Backed out changeset ccb4be659107 (bug 1754004)
Backed out changeset 659581d4159b (bug 1754004)
Backed out changeset 611ea76d7a9c (bug 1754004)
Backed out changeset 9b24b561698c (bug 1759572)
Backed out changeset f820e0f209ff (bug 1759563)
Backed out changeset 8d82066fa181 (bug 1759569)
Backed out changeset a2835afab1ad (bug 1754031)
2022-05-11 06:16:25 +03:00
Nika Layzell 4622361447 Bug 1754004 - Part 14: Fix potential skipping of async streams in nsMultiplexInputStream, r=asuth
Before this change, we could run into issues when an async stream
accepts new data and queues a runnable to notify the stream listener,
but before that stream listener's runnable is run, the target thread
reads data from the async stream, emptying it of any available data.
This would mean that the stream appears empty in
nsMultiplexInputStream::OnInputStreamReady, and the rest of the stream
is skipped.

This patch changes the logic in OnInputStreamReady to re-call AsyncWait
in those situations and avoid skipping over the empty stream, preventing
data loss.

This situation came up when running some HTTP tests under rr with the
socket process enabled, as the upload stream can both be read due to an
OnInputStreamReady callback and due to other calls in the HTTP
machinery, leading to this potential race. With the socket process
enabled, it is possible for the upload stream to be an async pipe, which
doesn't happen in the parent process due to stream normalization.

This change makes an assumption about the behaviour of streams
implementing `nsIAsyncInputStream` which I believe is correct right now,
and has been documented. I originally had other patches which modified
`Available()`'s definition to add an extra outparameter or added extra
methods, but this seemed much simpler and accurate based on my memory of
having read the Available() implementations for async streams in-tree.

A gtest was added for the failing situation using both nsPipe and DataPipe.

Differential Revision: https://phabricator.services.mozilla.com/D144451
2022-05-10 22:27:47 +00:00
Nika Layzell 77febbe6b5 Bug 1754004 - Part 11: Simplify the IPCStream serialization API, r=asuth,necko-reviewers,kershaw
As serializing IPCStream no longer requires a manager or FileDescriptor array,
the arguments are no longer necessary, and can be removed. The AutoIPCStream
helper can also be removed, as managed actors are no longer used for
serialization, so a delayed start callback is not necessary.

The delayed start parameter is also removed from nsIIPCSerializableInputStream
instances, but is still present as `aAllowLazy` on the toplevel serialization
methods.

Differential Revision: https://phabricator.services.mozilla.com/D141048
2022-05-10 22:27:46 +00:00
Nika Layzell 05141978a1 Bug 1759572 - AsyncLengthWaitHelper should be threadsafe, r=asuth
This works only because the only implementation of nsIAsyncInputStreamLength
happened to only run on the current thread. Bug 1754004, changes this, and requires the reference to be threadsafe.

Differential Revision: https://phabricator.services.mozilla.com/D141037
2022-05-10 22:27:41 +00:00
Nika Layzell bec160d610 Bug 1759563 - Add SerializedComplexity to limit the complexity of serialized IPCStream instances, r=asuth,necko-reviewers,dragana
This will improve the efficiency of serializing large data pipes, which in bad
cases can end up serializing very small amounts of data in individual pipes
over IPC, and acts as a compliment to the existing logic for limiting
serialized message sizes. It is also necessary for the changes in bug 1754004,
which require the ability to include FileDescriptor inline in the message,
which could blow out our FileDescriptor count limits if pipe creation was
unlimited.

In some tests, this change reduces the number of pipes required to serialize a
nsIInputStream from over 5000 to 1.

Differential Revision: https://phabricator.services.mozilla.com/D141036
2022-05-10 22:27:41 +00:00
Nika Layzell c7b5b788ec Bug 1754031 - AsyncWait implementations should support updating flags on an existing listener, r=asuth,necko-reviewers,dragana
This operation is often performed by nsAStreamCopier when switching
between the source and sink streams, in order to enable or disable the
WAIT_CLOSURE_ONLY flag. Failing to reset the wait flags can lead to a
NS_AsyncCopy hanging until the source or sink are closed when is
alternating between waiting on input and output streams. This patch
relaxes the incorrect checks on various input streams.

Differential Revision: https://phabricator.services.mozilla.com/D141034
2022-05-10 22:27:40 +00:00
Norisz Fay 9b58e7f95a Backed out 4 changesets (bug 1754031, bug 1759563, bug 1759572, bug 1759569) because they are linked to the backed out bug 1754004 CLOSED TREE
Backed out changeset a15de342dab9 (bug 1759572)
Backed out changeset e731c9fa7444 (bug 1759563)
Backed out changeset d70810d7b63a (bug 1759569)
Backed out changeset 14a5f40fc11d (bug 1754031)
2022-05-05 13:58:04 +03:00
Sebastian Hengst 107311111f Backed out 17 changesets (bug 1696894, bug 1754004) for causing crashes e.g. bug 1767808, and hanging Gmail (bug 1767918). a=backout DONTBUILD
Backed out changeset 63f17a06eba9 (bug 1754004)
Backed out changeset 017e1552d549 (bug 1754004)
Backed out changeset 010dfd821cf3 (bug 1696894)
Backed out changeset 96a39c2ba7a3 (bug 1754004)
Backed out changeset a147df47a0e3 (bug 1754004)
Backed out changeset 9018dd592230 (bug 1754004)
Backed out changeset 234ff9e092c2 (bug 1754004)
Backed out changeset c4f1e86992b6 (bug 1754004)
Backed out changeset 51bd50b57dd5 (bug 1754004)
Backed out changeset d95e7ad0eafa (bug 1754004)
Backed out changeset 35a69828091c (bug 1754004)
Backed out changeset 6802a4326963 (bug 1754004)
Backed out changeset e40e810e18fc (bug 1754004)
Backed out changeset 82b38c12b298 (bug 1754004)
Backed out changeset 0a6cf0817bf5 (bug 1754004)
Backed out changeset 6d8e51b3e8d7 (bug 1754004)
Backed out changeset 2059c2d0d880 (bug 1754004)
2022-05-05 11:27:42 +02:00
Nika Layzell c8105fdb07 Bug 1754004 - Part 14: Fix potential skipping of async streams in nsMultiplexInputStream, r=asuth
Before this change, we could run into issues when an async stream
accepts new data and queues a runnable to notify the stream listener,
but before that stream listener's runnable is run, the target thread
reads data from the async stream, emptying it of any available data.
This would mean that the stream appears empty in
nsMultiplexInputStream::OnInputStreamReady, and the rest of the stream
is skipped.

This patch changes the logic in OnInputStreamReady to re-call AsyncWait
in those situations and avoid skipping over the empty stream, preventing
data loss.

This situation came up when running some HTTP tests under rr with the
socket process enabled, as the upload stream can both be read due to an
OnInputStreamReady callback and due to other calls in the HTTP
machinery, leading to this potential race. With the socket process
enabled, it is possible for the upload stream to be an async pipe, which
doesn't happen in the parent process due to stream normalization.

This change makes an assumption about the behaviour of streams
implementing `nsIAsyncInputStream` which I believe is correct right now,
and has been documented. I originally had other patches which modified
`Available()`'s definition to add an extra outparameter or added extra
methods, but this seemed much simpler and accurate based on my memory of
having read the Available() implementations for async streams in-tree.

A gtest was added for the failing situation using both nsPipe and DataPipe.

Differential Revision: https://phabricator.services.mozilla.com/D144451
2022-05-03 23:30:37 +00:00
Nika Layzell b01e371213 Bug 1754004 - Part 11: Simplify the IPCStream serialization API, r=asuth,necko-reviewers,kershaw
As serializing IPCStream no longer requires a manager or FileDescriptor array,
the arguments are no longer necessary, and can be removed. The AutoIPCStream
helper can also be removed, as managed actors are no longer used for
serialization, so a delayed start callback is not necessary.

The delayed start parameter is also removed from nsIIPCSerializableInputStream
instances, but is still present as `aAllowLazy` on the toplevel serialization
methods.

Differential Revision: https://phabricator.services.mozilla.com/D141048
2022-05-03 23:30:36 +00:00
Nika Layzell 0f60988340 Bug 1759572 - AsyncLengthWaitHelper should be threadsafe, r=asuth
This works only because the only implementation of nsIAsyncInputStreamLength
happened to only run on the current thread. Bug 1754004, changes this, and requires the reference to be threadsafe.

Differential Revision: https://phabricator.services.mozilla.com/D141037
2022-05-03 23:30:32 +00:00
Nika Layzell c4802066fb Bug 1759563 - Add SerializedComplexity to limit the complexity of serialized IPCStream instances, r=asuth,necko-reviewers,dragana
This will improve the efficiency of serializing large data pipes, which in bad
cases can end up serializing very small amounts of data in individual pipes
over IPC, and acts as a compliment to the existing logic for limiting
serialized message sizes. It is also necessary for the changes in bug 1754004,
which require the ability to include FileDescriptor inline in the message,
which could blow out our FileDescriptor count limits if pipe creation was
unlimited.

In some tests, this change reduces the number of pipes required to serialize a
nsIInputStream from over 5000 to 1.

Differential Revision: https://phabricator.services.mozilla.com/D141036
2022-05-03 23:30:31 +00:00
Nika Layzell b01dddd32f Bug 1754031 - AsyncWait implementations should support updating flags on an existing listener, r=asuth,necko-reviewers,dragana
This operation is often performed by nsAStreamCopier when switching
between the source and sink streams, in order to enable or disable the
WAIT_CLOSURE_ONLY flag. Failing to reset the wait flags can lead to a
NS_AsyncCopy hanging until the source or sink are closed when is
alternating between waiting on input and output streams. This patch
relaxes the incorrect checks on various input streams.

Differential Revision: https://phabricator.services.mozilla.com/D141034
2022-05-03 23:30:30 +00:00
Butkovits Atila bc5f86a3c7 Backed out 19 changesets (bug 1759569, bug 1754004, bug 1759563, bug 1754031, bug 1696894, bug 1759572) for causing wpt failures. CLOSED TREE
Backed out changeset 110a8dce4b5d (bug 1696894)
Backed out changeset a62dab05c6cd (bug 1754004)
Backed out changeset 7cf122f6e19f (bug 1754004)
Backed out changeset 2aa9a0a9adbc (bug 1754004)
Backed out changeset cde16b2cdbfb (bug 1754004)
Backed out changeset 452fe0a15c99 (bug 1754004)
Backed out changeset eace8d4756ef (bug 1754004)
Backed out changeset 5e1fad91e935 (bug 1754004)
Backed out changeset eb6de0b1ab8e (bug 1754004)
Backed out changeset 1ac1908ed3d0 (bug 1754004)
Backed out changeset 473cad5b22ab (bug 1754004)
Backed out changeset 1923922be138 (bug 1754004)
Backed out changeset c7966d91f89e (bug 1754004)
Backed out changeset df5ce1f6712c (bug 1754004)
Backed out changeset a3f3f9761ada (bug 1754004)
Backed out changeset c8ec86e0a33b (bug 1759572)
Backed out changeset 6c102f8e3d4a (bug 1759563)
Backed out changeset bd3a2fcf4f0c (bug 1759569)
Backed out changeset 2541d8face65 (bug 1754031)
2022-05-03 06:00:22 +03:00
Nika Layzell 85f5368d4b Bug 1754004 - Part 14: Fix potential skipping of async streams in nsMultiplexInputStream, r=asuth
Before this change, we could run into issues when an async stream
accepts new data and queues a runnable to notify the stream listener,
but before that stream listener's runnable is run, the target thread
reads data from the async stream, emptying it of any available data.
This would mean that the stream appears empty in
nsMultiplexInputStream::OnInputStreamReady, and the rest of the stream
is skipped.

This patch changes the logic in OnInputStreamReady to re-call AsyncWait
in those situations and avoid skipping over the empty stream, preventing
data loss.

This situation came up when running some HTTP tests under rr with the
socket process enabled, as the upload stream can both be read due to an
OnInputStreamReady callback and due to other calls in the HTTP
machinery, leading to this potential race. With the socket process
enabled, it is possible for the upload stream to be an async pipe, which
doesn't happen in the parent process due to stream normalization.

This change makes an assumption about the behaviour of streams
implementing `nsIAsyncInputStream` which I believe is correct right now,
and has been documented. I originally had other patches which modified
`Available()`'s definition to add an extra outparameter or added extra
methods, but this seemed much simpler and accurate based on my memory of
having read the Available() implementations for async streams in-tree.

A gtest was added for the failing situation using both nsPipe and DataPipe.

Differential Revision: https://phabricator.services.mozilla.com/D144451
2022-05-02 20:44:27 +00:00
Nika Layzell 1d9407fb37 Bug 1754004 - Part 11: Simplify the IPCStream serialization API, r=asuth,necko-reviewers,kershaw
As serializing IPCStream no longer requires a manager or FileDescriptor array,
the arguments are no longer necessary, and can be removed. The AutoIPCStream
helper can also be removed, as managed actors are no longer used for
serialization, so a delayed start callback is not necessary.

The delayed start parameter is also removed from nsIIPCSerializableInputStream
instances, but is still present as `aAllowLazy` on the toplevel serialization
methods.

Differential Revision: https://phabricator.services.mozilla.com/D141048
2022-05-02 20:44:26 +00:00
Nika Layzell 34616d0f4e Bug 1759572 - AsyncLengthWaitHelper should be threadsafe, r=asuth
This works only because the only implementation of nsIAsyncInputStreamLength
happened to only run on the current thread. Bug 1754004, changes this, and requires the reference to be threadsafe.

Differential Revision: https://phabricator.services.mozilla.com/D141037
2022-05-02 20:44:21 +00:00
Nika Layzell d9e591a42c Bug 1759563 - Add SerializedComplexity to limit the complexity of serialized IPCStream instances, r=asuth,necko-reviewers,dragana
This will improve the efficiency of serializing large data pipes, which in bad
cases can end up serializing very small amounts of data in individual pipes
over IPC, and acts as a compliment to the existing logic for limiting
serialized message sizes. It is also necessary for the changes in bug 1754004,
which require the ability to include FileDescriptor inline in the message,
which could blow out our FileDescriptor count limits if pipe creation was
unlimited.

In some tests, this change reduces the number of pipes required to serialize a
nsIInputStream from over 5000 to 1.

Differential Revision: https://phabricator.services.mozilla.com/D141036
2022-05-02 20:44:21 +00:00
Nika Layzell 8f6f87fa09 Bug 1754031 - AsyncWait implementations should support updating flags on an existing listener, r=asuth,necko-reviewers,dragana
This operation is often performed by nsAStreamCopier when switching
between the source and sink streams, in order to enable or disable the
WAIT_CLOSURE_ONLY flag. Failing to reset the wait flags can lead to a
NS_AsyncCopy hanging until the source or sink are closed when is
alternating between waiting on input and output streams. This patch
relaxes the incorrect checks on various input streams.

Differential Revision: https://phabricator.services.mozilla.com/D141034
2022-05-02 20:44:20 +00:00