From 5a200e154347bde2a885ad1ede620d8d946b6420 Mon Sep 17 00:00:00 2001
From: Alexander Barton <alex@barton.de>
Date: Tue, 24 Jan 2012 02:44:57 +0100
Subject: [PATCH] New function Conn_UpdatePing() to update the "ping timestamp"

---
 src/ngircd/conn-func.c | 11 +++++++++++
 src/ngircd/conn-func.h |  4 +++-
 src/ngircd/conn.c      |  2 +-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/ngircd/conn-func.c b/src/ngircd/conn-func.c
index 23c20758..e81a79e9 100644
--- a/src/ngircd/conn-func.c
+++ b/src/ngircd/conn-func.c
@@ -43,6 +43,17 @@ Conn_UpdateIdle(CONN_ID Idx)
 	My_Connections[Idx].lastprivmsg = time(NULL);
 }
 
+/**
+ * Update "ping timestamp", the time of the last outgoing PING request.
+ *
+ * @param Idx Connection index.
+ */
+GLOBAL void
+Conn_UpdatePing(CONN_ID Idx)
+{
+	assert(Idx > NONE);
+	My_Connections[Idx].lastping = time(NULL);
+}
 
 /*
  * Get signon time of a connection.
diff --git a/src/ngircd/conn-func.h b/src/ngircd/conn-func.h
index 729860e4..21bbcdb0 100644
--- a/src/ngircd/conn-func.h
+++ b/src/ngircd/conn-func.h
@@ -29,7 +29,9 @@
 #endif
 
 
-GLOBAL void Conn_UpdateIdle PARAMS(( CONN_ID Idx ));
+GLOBAL void Conn_UpdateIdle PARAMS((CONN_ID Idx));
+GLOBAL void Conn_UpdatePing PARAMS((CONN_ID Idx));
+
 GLOBAL time_t Conn_GetSignon PARAMS((CONN_ID Idx));
 GLOBAL time_t Conn_GetIdle PARAMS(( CONN_ID Idx ));
 GLOBAL time_t Conn_LastPing PARAMS(( CONN_ID Idx ));
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index 35d74005..f743d1f8 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -1850,7 +1850,7 @@ Check_Connections(void)
 				   time(NULL) - Conf_PingTimeout) {
 				/* We need to send a PING ... */
 				LogDebug("Connection %d: sending PING ...", i);
-				My_Connections[i].lastping = time(NULL);
+				Conn_UpdatePing(i);
 				Conn_WriteStr(i, "PING :%s",
 					      Client_ID(Client_ThisServer()));
 			}