-
Notifications
You must be signed in to change notification settings - Fork 13
Make client close() do I/O work and leave no drop errs. #105
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
Conversation
|
Let me know if you'd like me to go the extra mile to make Drop on the Resource not block as well. We would need to be able to swap out the handle with an empty one so that we can then move the handle into the async context. |
smb/src/client/smb_client.rs
Outdated
| std::mem::swap(&mut conn_map, &mut self.connections); | ||
| for (_, c) in conn_map { | ||
| c._conn.close().await?; | ||
| if let Some(handler) = c._session.handler().upgrade() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put this logic inside Connection instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about I just do the Drop work for TreeMessageHandler, Connection, and Session? Otherwise, I can move this to OpenedConnectionInfo::close if you'd like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it looks like Connection::close doesn't actually do anything. It calls Worker::stop which just verifies the worker is there, but doesn't stop it or am I missing something? I'm also not disconnecting the Tree. I'll fix that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I think we can complete an implementation for a close() for Connection/Session/Tree, and then also implement a Drop like you did (partially?).
- Worker::close depends on the configuration.
- In the case of single-threaded - you are right. Would you like to fix that?
- In the case of multi-threaded/async, this DOES stop everything completely, via ParallelWorker::stop, that calls MultiWorkerBackend::stop impl, which results in actual stopping procedure for async/multi-threaded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do that. I probably won't get that done until this evening my time. I'll also add Drop for Connection so that it is closed.
edit: close for Tree may be more involved. It has a HandlerReference which prevents mutable access to the underlying handle (disconnect requires a mutable handle)
|
@cjbradfield Check out #108, and rebase over the new master once this change is merged! |
|
I'll rebase off of main once #108 merges provided you approve. |
37f774e to
2c65b98
Compare
2c65b98 to
4413c57
Compare
|
I was able to clean this up and add |
Also, #[allow(dead_code)] for dropping to silence warnings when not async
5a3a0ce to
6f3cf23
Compare
|
@cjbradfield Let's merge this PR -- please apply |
We have to still have a dropping flag for tree. Otherwise, we call drop() forever.
I'm having trouble getting test_smb_iterating_long_directory to pass, even on the This even happens on 0.8.1. I guess I'll ignore it for now? |
|
Locally, this test can cause serious stress on the target server, to the point at which it seems to hang the connection. |
This doesn't make Drop for Resource or the Client (or its dependencies) do I/O without blocking, but it does allow you to call Client::close() and have all of the tear down in that async context.
Furthermore, put a check in the Drop implementation for Resource so that it doesn't try to call close() if is_valid() is false. This prevents error spam if a user has already called async_close() on the resource rendering it empty.