[Windows] Closing connections properly on Windows#185
[Windows] Closing connections properly on Windows#185Tim-Zhang merged 2 commits intocontainerd:masterfrom
Conversation
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## master #185 +/- ##
=======================================
Coverage 24.39% 24.39%
=======================================
Files 17 17
Lines 2529 2529
=======================================
Hits 617 617
Misses 1912 1912
☔ View full report in Codecov by Sentry. |
The current closing logic was causing a deadlock because an unused pipe was being returned when the close was called on the listener. This sets a flag so we can detect that we should not use that pipe connection (which wasn't actually connected to a client but returned from the async call becuase we told it too return early). Signed-off-by: James Sturtevant <jstur@microsoft.com>
053d478 to
9d251f9
Compare
quanweiZhou
left a comment
There was a problem hiding this comment.
Thanks @jsturtevant, few comments.
|
|
||
| pub fn close(&self) -> Result<()> { | ||
| // release the ConnectNamedPipe thread by signaling the event and clean up event handle | ||
| self.shutting_down.store(true, Ordering::SeqCst); |
There was a problem hiding this comment.
I think when shutting_down == true, should return and not call set_event() and close_handle.
There was a problem hiding this comment.
we need both of these. set_event is what signals the thread that is suspended by GetOverlappedResult. The close_handle ensures that we don't leak the handle now that we've shut down. I might be able to move that to a Drop function for the pipelistener since I guess we could call accept again later after closing? I would need to think about that a bit more.
The current closing logic was causing a deadlock becuase an unused pipe was being returned when the close was called on the listenering. This sets a flag so we can detect that we should not use that pipe connection which wasn't actually connected to a client but returned from the async call becuase we told it too. Signed-off-by: James Sturtevant <jstur@microsoft.com>
[Windows] Closing connections properly on Windows
The current closing logic was causing a deadlock becuase an unused pipe was being returned when the close was called on the listenering. This sets a flag so we can detect that we should not use that pipe connection which wasn't actually connected to a client but returned from the async call becuase we told it too.
more info
I was using the skeleton example to test rust-extensions and found that there was a race condition when shutting the shim down.
Logs (with added logging) show that there are two (?!) clients but the code only connects once.
you can see there are two (!?) connections being handled, this is because the accept was returning an invalid handle when closing up causing the race condition on shutdown.
With this new logic we can see there is only ever one client (268):