about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2010-08-19 15:58:55 +0200
committerAlexander Barton <alex@barton.de>2010-08-19 15:58:55 +0200
commit04e38f17ae671f84b93e06c6eefa9235dd71d6ce (patch)
tree0f49b9ec0d11b1edaf5fa7f15302afbe5d128fda
parent32188d821b24198e4f6b5283fec1060b6700b66b (diff)
downloadngircd-04e38f17ae671f84b93e06c6eefa9235dd71d6ce.tar.gz
ngircd-04e38f17ae671f84b93e06c6eefa9235dd71d6ce.zip
Don't reset My_Connections[Idx].lastping when reading data
This fixes PING-PONG lag calculation (which resulted in "0" before).

The "lastping" time is still reset it if a time shift backwards has
been detected to prevent the daemon from miscalculating ping timeouts.
-rw-r--r--src/ngircd/conn.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index 58a3cbfd..d0548c98 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -1507,7 +1507,7 @@ Read_Request( CONN_ID Idx )
 	 * registered as a user, server or service connection. Don't update
 	 * otherwise, so users have at least Conf_PongTimeout seconds time to
 	 * register with the IRC server -- see Check_Connections().
-	 * Set "lastping", too, so we can handle time shifts backwards ... */
+	 * Update "lastping", too, if time shifted backwards ... */
 	c = Conn_GetClient(Idx);
 	if (c && (Client_Type(c) == CLIENT_USER
 		  || Client_Type(c) == CLIENT_SERVER
@@ -1517,7 +1517,8 @@ Read_Request( CONN_ID Idx )
 			My_Connections[Idx].bps = 0;
 
 		My_Connections[Idx].lastdata = t;
-		My_Connections[Idx].lastping = My_Connections[Idx].lastdata;
+		if (My_Connections[Idx].lastping > t)
+			My_Connections[Idx].lastping = t;
 	}
 
 	/* Look at the data in the (read-) buffer of this connection */