From 8900a1646e3759ed4c56ceff1931ed0b4ce4dd81 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 29 Nov 2022 10:48:20 -0600 Subject: [PATCH] refactor: do not report peer EOF as an error (#4275) --- libtransmission/peer-msgs.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libtransmission/peer-msgs.cc b/libtransmission/peer-msgs.cc index ec1543c7a..d57492df4 100644 --- a/libtransmission/peer-msgs.cc +++ b/libtransmission/peer-msgs.cc @@ -2138,7 +2138,7 @@ static void peerPulse(void* vmsgs) } } -static void gotError(tr_peerIo* /*io*/, short what, void* vmsgs) +static void gotError(tr_peerIo* io, short what, void* vmsgs) { auto* msgs = static_cast(vmsgs); @@ -2147,11 +2147,13 @@ static void gotError(tr_peerIo* /*io*/, short what, void* vmsgs) logdbg(msgs, fmt::format(FMT_STRING("libevent got a timeout, what={:d}"), what)); } - if ((what & (BEV_EVENT_EOF | BEV_EVENT_ERROR)) != 0) + if ((what & BEV_EVENT_EOF) != 0) { - logdbg( - msgs, - fmt::format(FMT_STRING("libevent got an error! what={:d}, errno={:d} ({:s})"), what, errno, tr_strerror(errno))); + logdbg(msgs, fmt::format("peer closed connection. {:s}", io->addrStr())); + } + else if ((what & BEV_EVENT_ERROR) != 0) + { + logdbg(msgs, fmt::format("libevent got an error! what={:d}, errno={:d} ({:s})", what, errno, tr_strerror(errno))); } msgs->publish(tr_peer_event::GotError(ENOTCONN));