devtools: wrap TcpStream to synchronize network operations#43472
Conversation
|
Related to this discussion: #general > TcpStream::try_clone() thread safety in devtools. If it's helpful, I can copy the details into a formal bug report for posterity. |
|
A happy side effect is that this removes a big source of flakiness in the existing devtools tests. On my machine with the |
eerii
left a comment
There was a problem hiding this comment.
Awesome change, thank you so much! I like how it looks, I left a few nits / style comments but great code.
I am testing it locally and it seems to have also fixed the flakiness I had on my machine with some devtools tests c:
Signed-off-by: Brent Schroeter <contact@brentsch.com>
Signed-off-by: Brent Schroeter <contact@brentsch.com>
Signed-off-by: Brent Schroeter <contact@brentsch.com>
Co-authored-by: eri <eri@igalia.com> Signed-off-by: Brent Schroeter <contact@brentsch.com>
Signed-off-by: Brent Schroeter <contact@brentsch.com>
abb7679 to
44cf3e9
Compare
|
@eerii thanks for the suggestions! Updated, and rebased on top of #43623. |
Signed-off-by: Brent Schroeter <contact@brentsch.com>
a18a595 to
25cb5c4
Compare
eerii
left a comment
There was a problem hiding this comment.
Thank you so much, everything looks great! c:
This reads to me like servo/components/devtools/protocol.rs Lines 39 to 84 in 66d232e |
|
You're absolutely right. I must have mixed up a merge or something. Thank you for catching it! Do you want to make a PR to fix? Otherwise I can submit one later today. |
This was supposed to be removed as part of servo#43472 see servo#43472 (comment) Signed-off-by: Bennet Bleßmann <bennet.blessmann+github@googlemail.com>
This was supposed to be removed as part of servo#43472 see servo#43472 (comment) and servo#43472 (comment) Signed-off-by: Bennet Bleßmann <bennet.blessmann+github@googlemail.com>
|
Opened PR #44006 |
Removes the `impl JsonPacketStream for TcpStream` that was supposed to be removed as part of #43472 > Testing: [..] Removing the JsonPacketStream implementation for TcpStream should discourage regressions due to improper use of raw streams. Confirmed in #43472 (comment) Testing: no new test needed as this only removes code Signed-off-by: Bennet Bleßmann <bennet.blessmann+github@googlemail.com>
Introduces a new type
DevtoolsConnection, which implements theJsonPacketStreamtrait with proper coordination of I/O across threads. This replaces the implementation ofJsonPacketStreamfor rawTcpStreams, which was susceptible to interleaving writes when cloned across threads.DevtoolsConnectionalso defensively synchronizes read operations. These are less likely to cause issues: in practice actors should never independently pull incoming messages without centralized coordination.Testing: No new tests, as interleaving writes are difficult to evoke deterministically. Removing the
JsonPacketStreamimplementation forTcpStreamshould discourage regressions due to improper use of raw streams.