Skip to content

Commit 4590b9c

Browse files
authored
close listener connection on TimedOut and BrokenPipe errors (#3648)
* close listener connection on TimedOut and BrokerPipe errors * use matches macro to generate jump table instead of chain of conditions
1 parent fdd4663 commit 4590b9c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

sqlx-postgres/src/listener.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,14 @@ impl PgListener {
279279
// The connection is dead, ensure that it is dropped,
280280
// update self state, and loop to try again.
281281
Err(Error::Io(err))
282-
if (err.kind() == io::ErrorKind::ConnectionAborted
283-
|| err.kind() == io::ErrorKind::UnexpectedEof) =>
282+
if matches!(
283+
err.kind(),
284+
io::ErrorKind::ConnectionAborted |
285+
io::ErrorKind::UnexpectedEof |
286+
// see ERRORS section in tcp(7) man page (https://man7.org/linux/man-pages/man7/tcp.7.html)
287+
io::ErrorKind::TimedOut |
288+
io::ErrorKind::BrokenPipe
289+
) =>
284290
{
285291
if let Some(mut conn) = self.connection.take() {
286292
self.buffer_tx = conn.inner.stream.notifications.take();

0 commit comments

Comments
 (0)