]> arthur.barton.de Git - ngircd.git/commitdiff
Enhance debug logging for PONG commands
authorAlexander Barton <alex@barton.de>
Mon, 25 May 2020 21:30:07 +0000 (23:30 +0200)
committerAlexander Barton <alex@barton.de>
Mon, 25 May 2020 21:30:07 +0000 (23:30 +0200)
Distinguish between expected and unexpected PONG commands.

src/ngircd/irc-login.c

index f682e216f273279501d33a036973cdb738ba9848..368a03d46bef6ff775ecc029051b427d21cbef32 100644 (file)
@@ -877,9 +877,17 @@ IRC_PONG(CLIENT *Client, REQUEST *Req)
                    (long)(time(NULL) - Conn_GetSignon(conn)),
                    time(NULL) - Conn_GetSignon(conn) == 1 ? "" : "s",
                    Client_UserCount(), Channel_CountVisible(NULL));
-       } else
-               LogDebug("Connection %d: received PONG. Lag: %ld seconds.",
-                        conn, (long)(time(NULL) - Conn_LastPing(conn)));
+       }
+#ifdef DEBUG
+       else {
+               if (Conn_LastPing(conn) > 1)
+                       LogDebug("Connection %d: received PONG. Lag: %ld seconds.",
+                                conn, (long)(time(NULL) - Conn_LastPing(conn)));
+               else
+                       LogDebug("Got unexpected PONG on connection %d. Ignored.",
+                                conn);
+       }
+#endif
 
        /* We got a PONG, so signal that none is pending on this connection. */
        Conn_UpdatePing(conn, 1);