]> Dogcows Code - chaz/openbox/commitdiff
use unique IDs for pings rather than a timestamp. avoids duplicates.
authorDana Jansens <danakj@orodu.net>
Wed, 16 Jan 2008 23:16:49 +0000 (18:16 -0500)
committerDana Jansens <danakj@orodu.net>
Wed, 16 Jan 2008 23:16:49 +0000 (18:16 -0500)
openbox/ping.c
openbox/ping.h

index eed094796045562fc7ef328f6e2d816408420e45..92fb8630c37902e62d3344169d83423bbb16536c 100644 (file)
@@ -29,12 +29,13 @@ typedef struct _ObPingTarget
 {
     ObClient *client;
     ObPingEventHandler h;
-    Time sent;
+    guint32 id;
     gint waiting;
 } ObPingTarget;
 
 static GSList *ping_targets = NULL;
 static gboolean active = FALSE;
+static guint32 ping_next_id = 1;
 
 #define PING_TIMEOUT (G_USEC_PER_SEC * 3)
 /*! Warn the user after this many PING_TIMEOUT intervals */
@@ -79,7 +80,7 @@ void ping_stop(struct _ObClient *c)
     ping_end(c, NULL);
 }
 
-void ping_got_pong(Time timestamp)
+void ping_got_pong(guint32 id)
 {
     GSList *it;
     ObPingTarget *t;
@@ -87,9 +88,8 @@ void ping_got_pong(Time timestamp)
     /* make sure we're not already pinging it */
     for (it = ping_targets; it != NULL; it = g_slist_next(it)) {
         t = it->data;
-        if (t->sent == timestamp) {
-            /*ob_debug("PONG: '%s' (timestamp %lu)\n", t->client->title,
-                     t->sent);*/
+        if (t->id == id) {
+            /*g_print("-PONG: '%s' (id %u)\n", t->client->title, t->id);*/
             if (t->waiting > PING_TIMEOUT_WARN) {
                 /* we had notified that they weren't responding, so now we
                    need to notify that they are again */
@@ -101,16 +101,15 @@ void ping_got_pong(Time timestamp)
     }
 
     if (it == NULL)
-        ob_debug("Got PONG with timestamp %lu but not waiting for one\n",
-                 timestamp);
+        ob_debug("Got PONG with id %u but not waiting for one\n", id);
 }
 
 static void ping_send(ObPingTarget *t)
 {
-    t->sent = event_get_server_time();
-    /*ob_debug("PING: '%s' (timestamp %lu)\n", t->client->title, t->sent);*/
+    t->id = ping_next_id++;
+    /*g_print("+PING: '%s' (id %u)\n", t->client->title, t->id);*/
     PROP_MSG_TO(t->client->window, t->client->window, wm_protocols,
-                prop_atoms.net_wm_ping, t->sent, t->client->window, 0, 0,
+                prop_atoms.net_wm_ping, t->id, t->client->window, 0, 0,
                 NoEventMask);
 }
 
index 0b6dfeadbf51b978dd0e6c45abae1ef0d0a63868..9f5c157b704da0e251aa58fedd14b30a6df9c130 100644 (file)
@@ -36,6 +36,6 @@ typedef void (*ObPingEventHandler) (struct _ObClient *c, gboolean dead);
 void ping_start(struct _ObClient *c, ObPingEventHandler h);
 void ping_stop(struct _ObClient *c);
 
-void ping_got_pong(Time timestamp);
+void ping_got_pong(guint32 id);
 
 #endif
This page took 0.027436 seconds and 4 git commands to generate.