Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(websocket): lock conflict between emit and poll #213

Merged
merged 1 commit into from
Aug 14, 2022
Merged

Conversation

SSebo
Copy link
Contributor

@SSebo SSebo commented Aug 10, 2022

No description provided.

@codecov
Copy link

codecov bot commented Aug 10, 2022

Codecov Report

Merging #213 (f3dc134) into main (31996cf) will decrease coverage by 0.38%.
The diff coverage is 87.80%.

@@            Coverage Diff             @@
##             main     #213      +/-   ##
==========================================
- Coverage   86.77%   86.38%   -0.39%     
==========================================
  Files          30       30              
  Lines        2351     2358       +7     
==========================================
- Hits         2040     2037       -3     
- Misses        311      321      +10     
Impacted Files Coverage Δ
...asynchronous/async_transports/websocket_general.rs 76.36% <78.57%> (-11.45%) ⬇️
engineio/src/transports/websocket.rs 92.85% <90.90%> (-2.15%) ⬇️
engineio/src/transports/websocket_secure.rs 93.10% <90.90%> (-2.06%) ⬇️
...eio/src/asynchronous/async_transports/websocket.rs 89.18% <100.00%> (+0.30%) ⬆️
.../asynchronous/async_transports/websocket_secure.rs 88.00% <100.00%> (+0.32%) ⬆️
socketio/src/socket.rs 76.08% <100.00%> (-0.76%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@SSebo SSebo changed the title chore(socket): simplify handle_engineio_packet fix(websocket): lock conflict between emit and poll Aug 10, 2022
@SSebo SSebo force-pushed the main branch 2 times, most recently from b80dcf7 to 7a9af9d Compare August 11, 2022 04:43
@1c3t3a
Copy link
Owner

1c3t3a commented Aug 12, 2022

Hi @SSebo, first of all thanks for the contribution and for finding this bug! That is great :) For your PR I am not so sure about the implementation. The async transport never actually locks at the same time, so the only problem is the sync transport. A minimal inversiv and nice change would be to find a way for removing the lock from the sync transport. I assume this should be possible as all methods from the Transport interface only take &self instead of .&mut self. Your solution would work, but basically gives access to another clone of the sender which is harder to read and more difficult to reason about.

@SSebo SSebo force-pushed the main branch 2 times, most recently from d31b2b5 to 17c8f5e Compare August 12, 2022 13:59
@SSebo
Copy link
Contributor Author

SSebo commented Aug 12, 2022

@1c3t3a I agree! I found the &mut self is because of the StreamExt api, so manual write a poll_next function can get ride of the &mut self.

@SSebo
Copy link
Contributor Author

SSebo commented Aug 13, 2022

@1c3t3a the code is more reasonable now, PTAL

Copy link
Owner

@1c3t3a 1c3t3a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks a lot!

@1c3t3a 1c3t3a merged commit 4eea9b7 into 1c3t3a:main Aug 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants