Skip to content

Commit

Permalink
fix: add timeout to split stream close (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
aembke committed May 8, 2023
1 parent 4668d41 commit 78f5395
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fred"
version = "6.2.1"
version = "6.2.2"
authors = ["Alec Embke <[email protected]>"]
edition = "2021"
description = "An async Redis client built on Tokio."
Expand Down
18 changes: 14 additions & 4 deletions src/protocol/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -937,10 +937,20 @@ impl RedisWriter {
///
/// Returns the in-flight commands that had not received a response.
pub async fn graceful_close(mut self) -> CommandBuffer {
let _ = self.sink.close().await;
if let Some(mut reader) = self.reader {
let _ = reader.wait().await;
}
let timeout = globals().default_connection_timeout_ms();
let _ = utils::apply_timeout(
async {
let _ = self.sink.close().await;
if let Some(mut reader) = self.reader {
let _ = reader.wait().await;
}

Ok::<_, RedisError>(())
},
timeout,
)
.await;

self.buffer.lock().drain(..).collect()
}
}
Expand Down

0 comments on commit 78f5395

Please sign in to comment.