Always try to close a connection with errors immediately, but try hard
to avoid too much recursion.
Without this patch, an outgoing server connection could get stuck in an
"endless" state trying to write out data over and over again.
This tries to fix
04de1423eb26.
if (errno == EAGAIN || errno == EINTR)
return true;
if (errno == EAGAIN || errno == EINTR)
return true;
- /* Log write errors but do not close the connection yet.
- * Calling Conn_Close() now could result in too many recursive calls.
- */
- if (!Conn_OPTION_ISSET(&My_Connections[Idx], CONN_ISCLOSING))
+ if (!Conn_OPTION_ISSET(&My_Connections[Idx], CONN_ISCLOSING)) {
Log(LOG_ERR,
"Write error on connection %d (socket %d): %s!",
Idx, My_Connections[Idx].sock, strerror(errno));
Log(LOG_ERR,
"Write error on connection %d (socket %d): %s!",
Idx, My_Connections[Idx].sock, strerror(errno));
+ Conn_Close(Idx, "Write error", NULL, false);
+ } else
LogDebug("Recursive write error on connection %d (socket %d): %s!",
Idx, My_Connections[Idx].sock, strerror(errno));
LogDebug("Recursive write error on connection %d (socket %d): %s!",
Idx, My_Connections[Idx].sock, strerror(errno));