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 invalid response id after closing file #77

Merged
merged 4 commits into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/changelog.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#[allow(unused_imports)]
use crate::*;

/// ## Improved
/// - Fix: change the drop of `OwnedHandle` to wait for the close request in order to
/// avoid invalid response id after closing file
#[doc(hidden)]
pub mod unreleased {}

Expand Down
13 changes: 8 additions & 5 deletions src/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ impl Drop for OwnedHandle {
if Arc::strong_count(handle) == 1 {
// This is the last reference to the arc
let id = write_end.get_id_mut();
let _ = write_end.send_close_request(id, Cow::Borrowed(handle));

// Requests is already added to write buffer, so wakeup
// the `flush_task`.
self.get_auxiliary().wakeup_flush_task();
if let Ok(response) = write_end.send_close_request(id, Cow::Borrowed(handle)) {
// Requests is already added to write buffer, so wakeup
// the `flush_task`.
self.get_auxiliary().wakeup_flush_task();
tokio::spawn(async move {
let _ = response.wait().await;
});
}
}
}
}
Expand Down