repo: ngircd
action: commit
revision: 
path_from: 
revision_from: bc20f9ec1076a67a81ed8e7c3489ffbdf3387e53:
path_to: 
revision_to: 
git.thebackupbox.net
ngircd
git clone git://git.thebackupbox.net/ngircd
commit bc20f9ec1076a67a81ed8e7c3489ffbdf3387e53
Author: Alexander Barton 
Date:   Tue Jan 24 02:46:12 2012 +0100

    Send a PING at the end of the server sync to detect it

    At the end of sending all "state" to the remote server, a PING command
    is sent to request a PONG reply. Until then, no "regual" PING was sent,
    so Conn_LastPing() is null and now becomes non-null in the
    PONG command handler.

    So the servers are still synchronizing when Conn_LastPing()
    is 0, which could easily be tested.

diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c
index 54818fe4879f05d2d05f438cb3e98d646818641f..
index ..133a0e5fa79ed7cda29bdf46b5736047a5ac7809 100644
--- a/src/ngircd/irc-login.c
+++ b/src/ngircd/irc-login.c
@@ -889,15 +889,16 @@ IRC_PONG(CLIENT *Client, REQUEST *Req)
 	}
 #endif

-#ifdef DEBUG
-	if (conn > NONE)
-		Log(LOG_DEBUG,
-			"Connection %d: received PONG. Lag: %ld seconds.", conn,
-			time(NULL) - Conn_LastPing(Client_Conn(Client)));
-	else
-		 Log(LOG_DEBUG,
-			"Connection %d: received PONG.", conn);
-#endif
+	if (Client_Type(Client) == CLIENT_SERVER && Conn_LastPing(conn) == 0) {
+		Log(LOG_INFO,
+		    "Synchronization with \"%s\" done (connection %d): %ld seconds [%ld users, %ld channels]",
+		    Client_ID(Client), conn, time(NULL) - Conn_GetSignon(conn),
+		    Client_UserCount(), Channel_CountVisible(NULL));
+		Conn_UpdatePing(conn);
+	} else
+		LogDebug("Connection %d: received PONG. Lag: %ld seconds.",
+			 conn, time(NULL) - Conn_LastPing(conn));
+
 	return CONNECTED;
 } /* IRC_PONG */

diff --git a/src/ngircd/numeric.c b/src/ngircd/numeric.c
index 0440768c6151ccab7a5d8e3d043c2056e1b6d321..
index ..d59a1dc3a9be6895de5f2565337fe8e29a3fbb40 100644
--- a/src/ngircd/numeric.c
+++ b/src/ngircd/numeric.c
@@ -384,6 +384,10 @@ IRC_Num_ENDOFMOTD(CLIENT * Client, UNUSED REQUEST * Req)
 	}
 #endif

+	if (!IRC_WriteStrClient(Client, "PING :%s",
+	    Client_ID(Client_ThisServer())))
+		return DISCONNECTED;
+
 	return CONNECTED;
 } /* IRC_Num_ENDOFMOTD */

-----END OF PAGE-----