Skip to content

Commit 292962e

Browse files
authored
Modify the log output on EPIPE or ECONNRESET (#38)
1 parent 0c3bf1b commit 292962e

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

trantor/net/inner/TcpConnectionImpl.cc

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ void TcpConnectionImpl::readCallback()
6868
}
6969
else if (n < 0)
7070
{
71+
if (errno == EPIPE || errno == ECONNRESET) // TODO: any others?
72+
{
73+
LOG_DEBUG << "EPIPE or ECONNRESET, erron=" << errno;
74+
return;
75+
}
7176
LOG_SYSERR << "read socket error";
7277
}
7378
extendLife();
@@ -136,13 +141,12 @@ void TcpConnectionImpl::writeCallback()
136141
}
137142
else
138143
{
139-
// error
140144
if (errno != EWOULDBLOCK)
141145
{
142-
LOG_SYSERR << "TcpConnectionImpl::sendInLoop";
143-
if (errno == EPIPE ||
144-
errno == ECONNRESET) // TODO: any others?
146+
// TODO: any others?
147+
if (errno == EPIPE || errno == ECONNRESET)
145148
{
149+
LOG_DEBUG << "EPIPE or ECONNRESET, erron=" << errno;
146150
return;
147151
}
148152
LOG_SYSERR << "Unexpected error(" << errno << ")";
@@ -183,13 +187,13 @@ void TcpConnectionImpl::writeCallback()
183187
}
184188
else
185189
{
186-
// error
187190
if (errno != EWOULDBLOCK)
188191
{
189-
LOG_SYSERR << "TcpConnectionImpl::sendInLoop";
190-
if (errno == EPIPE ||
191-
errno == ECONNRESET) // TODO: any others?
192+
// TODO: any others?
193+
if (errno == EPIPE || errno == ECONNRESET)
192194
{
195+
LOG_DEBUG << "EPIPE or ECONNRESET, erron="
196+
<< errno;
193197
return;
194198
}
195199
LOG_SYSERR << "Unexpected error(" << errno
@@ -249,6 +253,8 @@ void TcpConnectionImpl::handleClose()
249253
void TcpConnectionImpl::handleError()
250254
{
251255
int err = _socketPtr->getSocketError();
256+
if (err == 0)
257+
return;
252258
if (err != 104)
253259
LOG_ERROR << "TcpConnectionImpl::handleError [" << _name
254260
<< "] - SO_ERROR = " << err << " " << strerror_tl(err);
@@ -321,6 +327,7 @@ void TcpConnectionImpl::sendInLoop(const char *buffer, size_t length)
321327
{
322328
if (errno == EPIPE || errno == ECONNRESET) // TODO: any others?
323329
{
330+
LOG_DEBUG << "EPIPE or ECONNRESET, erron=" << errno;
324331
return;
325332
}
326333
LOG_SYSERR << "Unexpected error(" << errno << ")";
@@ -711,10 +718,10 @@ void TcpConnectionImpl::sendFileInLoop(const BufferNodePtr &filePtr)
711718
{
712719
if (errno != EWOULDBLOCK)
713720
{
714-
LOG_SYSERR << "TcpConnectionImpl::sendFileInLoop";
715-
if (errno == EPIPE ||
716-
errno == ECONNRESET) // TODO: any others?
721+
// TODO: any others?
722+
if (errno == EPIPE || errno == ECONNRESET)
717723
{
724+
LOG_DEBUG << "EPIPE or ECONNRESET, erron=" << errno;
718725
return;
719726
}
720727
LOG_SYSERR << "Unexpected error(" << errno << ")";

trantor/net/ssl/SSLConnection.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ void SSLConnection::doHandshaking()
140140
else
141141
{
142142
// ERR_print_errors(err);
143-
LOG_FATAL << "SSL handshake err";
143+
LOG_DEBUG << "SSL handshake err: " << err;
144144
_ioChannelPtr->disableReading();
145145
_status = SSLStatus::DisConnected;
146146
forceClose();

0 commit comments

Comments
 (0)