Correctly implement AsLL pong.
authorMichael Poole <mdpoole@troilus.org>
Wed, 5 Apr 2006 00:09:48 +0000 (00:09 +0000)
committerMichael Poole <mdpoole@troilus.org>
Wed, 5 Apr 2006 00:09:48 +0000 (00:09 +0000)
src/proto-p10.c (irc_pong_asll): New function.
  (cmd_ping): Use it.
git-archimport-id: srvx@srvx.net--2006/srvx--devo--1.3--patch-5

ChangeLog
src/proto-p10.c

index ee4db9050fbf53c5ecc58cee41ae3e8480c74d25..973a4e80ceddeb8975877890a3729c5edcd02ee7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,20 @@
 # arch-tag: automatic-ChangeLog--srvx@srvx.net--2006/srvx--devo--1.3
 #
 
+2006-04-05 00:09:48 GMT        Michael Poole <mdpoole@troilus.org>     patch-5
+
+    Summary:
+      Correctly implement AsLL pong.
+    Revision:
+      srvx--devo--1.3--patch-5
+
+    src/proto-p10.c (irc_pong_asll): New function.
+      (cmd_ping): Use it.
+
+    modified files:
+     ChangeLog src/proto-p10.c
+
+
 2006-04-05 00:08:04 GMT        Michael Poole <mdpoole@troilus.org>     patch-4
 
     Summary:
index c7d69b06476c68a124cdf270ebeb215545f1a526..d44d8a288c664722f19ce63a72bfb8d9bab4ed5c 100644 (file)
@@ -596,6 +596,21 @@ irc_pong(const char *who, const char *data)
     putsock("%s " P10_PONG " %s :%s", self->numeric, who, data);
 }
 
+void
+irc_pong_asll(const char *who, const char *orig_ts)
+{
+    char *delim;
+    struct timeval orig;
+    struct timeval now;
+    int diff;
+
+    orig.tv_sec = strtoul(orig_ts, &delim, 10);
+    orig.tv_usec = (*delim == '.') ? strtoul(delim + 1, NULL, 10) : 0;
+    gettimeofday(&now, NULL);
+    diff = (now.tv_sec - orig.tv_sec) * 1000 + (now.tv_usec - orig.tv_usec) / 1000;
+    putsock("%s " P10_PONG " %s %s %d " FMT_TIME_T ".%06u", self->numeric, who, orig_ts, diff, now.tv_sec, (unsigned)now.tv_usec);
+}
+
 void
 irc_pass(const char *passwd)
 {
@@ -957,8 +972,8 @@ static CMD_FUNC(cmd_ping)
     struct server *srv;
     struct userNode *un;
 
-    if(argc > 3)
-        irc_pong(argv[2], argv[1]);
+    if (argc > 3)
+        irc_pong_asll(argv[2], argv[3]);
     else if ((srv = GetServerH(origin)))
         irc_pong(self->name, srv->numeric);
     else if ((un = GetUserH(origin)))