Skip to content

Commit 114939a

Browse files
authored
Merge pull request #917 from copy/main
fix(tcp): only reset remote_last_ts if some data is enqueued
2 parents 4c27918 + 18c131e commit 114939a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/socket/tcp.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1123,21 +1123,21 @@ impl<'a> Socket<'a> {
11231123
return Err(SendError::InvalidState);
11241124
}
11251125

1126-
// The connection might have been idle for a long time, and so remote_last_ts
1127-
// would be far in the past. Unless we clear it here, we'll abort the connection
1128-
// down over in dispatch() by erroneously detecting it as timed out.
1129-
if self.tx_buffer.is_empty() {
1130-
self.remote_last_ts = None
1131-
}
1132-
1133-
let _old_length = self.tx_buffer.len();
1126+
let old_length = self.tx_buffer.len();
11341127
let (size, result) = f(&mut self.tx_buffer);
11351128
if size > 0 {
1129+
// The connection might have been idle for a long time, and so remote_last_ts
1130+
// would be far in the past. Unless we clear it here, we'll abort the connection
1131+
// down over in dispatch() by erroneously detecting it as timed out.
1132+
if old_length == 0 {
1133+
self.remote_last_ts = None
1134+
}
1135+
11361136
#[cfg(any(test, feature = "verbose"))]
11371137
tcp_trace!(
11381138
"tx buffer: enqueueing {} octets (now {})",
11391139
size,
1140-
_old_length + size
1140+
old_length + size
11411141
);
11421142
}
11431143
Ok(result)

0 commit comments

Comments
 (0)