]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/conn.c
Fix PING-PONG handling when processing backlog in read buffers
[ngircd-alex.git] / src / ngircd / conn.c
index c304fdb574ffc497552f76fec4c531bb5c359abe..94c6c4a8b1683fa75ca3fd4f6daaf98884d29dfd 100644 (file)
@@ -1866,6 +1866,9 @@ Check_Connections(void)
        CLIENT *c;
        CONN_ID i;
        char msg[64];
        CLIENT *c;
        CONN_ID i;
        char msg[64];
+       time_t time_now;
+
+       time_now = time(NULL);
 
        for (i = 0; i < Pool_Size; i++) {
                if (My_Connections[i].sock < 0)
 
        for (i = 0; i < Pool_Size; i++) {
                if (My_Connections[i].sock < 0)
@@ -1880,7 +1883,7 @@ Check_Connections(void)
                            My_Connections[i].lastdata) {
                                /* We already sent a ping */
                                if (My_Connections[i].lastping <
                            My_Connections[i].lastdata) {
                                /* We already sent a ping */
                                if (My_Connections[i].lastping <
-                                   time(NULL) - Conf_PongTimeout) {
+                                   time_now - Conf_PongTimeout) {
                                        /* Timeout */
                                        snprintf(msg, sizeof(msg),
                                                 "Ping timeout: %d seconds",
                                        /* Timeout */
                                        snprintf(msg, sizeof(msg),
                                                 "Ping timeout: %d seconds",
@@ -1889,10 +1892,10 @@ Check_Connections(void)
                                        Conn_Close(i, NULL, msg, true);
                                }
                        } else if (My_Connections[i].lastdata <
                                        Conn_Close(i, NULL, msg, true);
                                }
                        } else if (My_Connections[i].lastdata <
-                                  time(NULL) - Conf_PingTimeout) {
+                                  time_now - Conf_PingTimeout) {
                                /* We need to send a PING ... */
                                LogDebug("Connection %d: sending PING ...", i);
                                /* We need to send a PING ... */
                                LogDebug("Connection %d: sending PING ...", i);
-                               Conn_UpdatePing(i);
+                               Conn_UpdatePing(i, time_now);
                                Conn_WriteStr(i, "PING :%s",
                                              Client_ID(Client_ThisServer()));
                        }
                                Conn_WriteStr(i, "PING :%s",
                                              Client_ID(Client_ThisServer()));
                        }
@@ -1903,7 +1906,7 @@ Check_Connections(void)
                         * still not registered. */
 
                        if (My_Connections[i].lastdata <
                         * still not registered. */
 
                        if (My_Connections[i].lastdata <
-                           time(NULL) - Conf_PongTimeout) {
+                           time_now - Conf_PongTimeout) {
                                LogDebug
                                    ("Unregistered connection %d timed out ...",
                                     i);
                                LogDebug
                                    ("Unregistered connection %d timed out ...",
                                     i);