Add initial version of the TCP wrapper#2595
Merged
stevenengler merged 3 commits intoshadow:mainfrom Dec 9, 2022
Merged
Conversation
For most syscalls, we simply call the C syscall handler from the rust syscall handler just like we did before. This lets us incrementally add support for individual syscalls for this `TcpSocket` wrapper.
This causes shadow to panic when TCP sockets are closed. This is fixed in the next commit.
The `LegacyCallbackQueue` prevents circular borrows when running event listeners. For the `close()` syscall, this prevents the panic where the syscall handler mutably borrows the `TcpSocket`, the inner C `TCP` object changes to the `CLOSED` state, an epoll event listener callback is run, and the callback takes a shared borrow of the `TcpSocket`. A temporary `LegacyCallbackQueue` is stored as a thread-local so that the `LegacyDescriptor` can access it without us having to update large amounts of C code to pass it through to everywhere we need it. Since we're deprecating/removing the C code, it's not worth the effort / possible breakage to update it.
Codecov ReportBase: 0.00% // Head: 66.67% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #2595 +/- ##
=========================================
+ Coverage 0 66.67% +66.67%
=========================================
Files 0 198 +198
Lines 0 29323 +29323
Branches 0 5773 +5773
=========================================
+ Hits 0 19551 +19551
- Misses 0 5222 +5222
- Partials 0 4550 +4550
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
sporksmith
approved these changes
Dec 9, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For most syscalls, we simply call the C syscall handler from the rust syscall handler just like we did before. This lets us incrementally add support for individual syscalls for this
TcpSocketwrapper.The
LegacyCallbackQueueprevents circular borrows when running event listeners. For theclose()syscall, this prevents a panic where the syscall handler mutably borrows theTcpSocket, the inner CTCPobject changes to theCLOSEDstate, an epoll event listener callback is run, and the callback takes a shared borrow of theTcpSocket. Just like we do with the rust file objects, the callback queue allows us to delay callbacks until later.A temporary
LegacyCallbackQueueis stored as a thread-local so that theLegacyDescriptorcan access it without us having to update large amounts of C code to pass it through to everywhere we need it. Since we're deprecating/removing the C code, it's not worth the effort / possible breakage to update it.