]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Always initiate closing a connection on errors.
authorAlexander Barton <alex@barton.de>
Fri, 24 Nov 2023 17:16:36 +0000 (18:16 +0100)
committerAlexander Barton <alex@barton.de>
Sat, 6 Jan 2024 15:21:01 +0000 (16:21 +0100)
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.

src/ngircd/conn.c

index e8ef68f36c7ec32642b806c78e5f70d4dc01feea..7097f1acb6028f659600199275d2b87052fb2c81 100644 (file)
@@ -1291,14 +1291,12 @@ Handle_Write( CONN_ID Idx )
                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));
-               else
+                       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));