Skip to content

Commit

Permalink
Merge pull request #12 from radsquirrel-forks/shutdown-fix
Browse files Browse the repository at this point in the history
Fix socket and memory leak on shutdown
  • Loading branch information
HsuJv authored Aug 29, 2024
2 parents 2d2767c + f13db9d commit a427dc2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/client/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ where
let mut pending = 0;

// main traffic loop
while let Err(oneshot::error::TryRecvError::Empty) = stop_ch.try_recv() {
loop {
if pending > 0 {
match conn_ch.try_send(Ok(buffer[0..pending].to_owned())) {
Err(TrySendError::Full(_message)) => (),
Expand All @@ -480,6 +480,7 @@ where
}

tokio::select! {
_ = &mut stop_ch => break,
result = stream.read(&mut buffer), if pending == 0 => {
match result {
Ok(nread) => {
Expand Down

0 comments on commit a427dc2

Please sign in to comment.