use unique IDs for pings rather than a timestamp. avoids duplicates.
This commit is contained in:
parent
9e18dbe0ee
commit
2ee4251092
2 changed files with 10 additions and 11 deletions
|
@ -29,12 +29,13 @@ typedef struct _ObPingTarget
|
||||||
{
|
{
|
||||||
ObClient *client;
|
ObClient *client;
|
||||||
ObPingEventHandler h;
|
ObPingEventHandler h;
|
||||||
Time sent;
|
guint32 id;
|
||||||
gint waiting;
|
gint waiting;
|
||||||
} ObPingTarget;
|
} ObPingTarget;
|
||||||
|
|
||||||
static GSList *ping_targets = NULL;
|
static GSList *ping_targets = NULL;
|
||||||
static gboolean active = FALSE;
|
static gboolean active = FALSE;
|
||||||
|
static guint32 ping_next_id = 1;
|
||||||
|
|
||||||
#define PING_TIMEOUT (G_USEC_PER_SEC * 3)
|
#define PING_TIMEOUT (G_USEC_PER_SEC * 3)
|
||||||
/*! Warn the user after this many PING_TIMEOUT intervals */
|
/*! Warn the user after this many PING_TIMEOUT intervals */
|
||||||
|
@ -79,7 +80,7 @@ void ping_stop(struct _ObClient *c)
|
||||||
ping_end(c, NULL);
|
ping_end(c, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ping_got_pong(Time timestamp)
|
void ping_got_pong(guint32 id)
|
||||||
{
|
{
|
||||||
GSList *it;
|
GSList *it;
|
||||||
ObPingTarget *t;
|
ObPingTarget *t;
|
||||||
|
@ -87,9 +88,8 @@ void ping_got_pong(Time timestamp)
|
||||||
/* make sure we're not already pinging it */
|
/* make sure we're not already pinging it */
|
||||||
for (it = ping_targets; it != NULL; it = g_slist_next(it)) {
|
for (it = ping_targets; it != NULL; it = g_slist_next(it)) {
|
||||||
t = it->data;
|
t = it->data;
|
||||||
if (t->sent == timestamp) {
|
if (t->id == id) {
|
||||||
/*ob_debug("PONG: '%s' (timestamp %lu)\n", t->client->title,
|
/*g_print("-PONG: '%s' (id %u)\n", t->client->title, t->id);*/
|
||||||
t->sent);*/
|
|
||||||
if (t->waiting > PING_TIMEOUT_WARN) {
|
if (t->waiting > PING_TIMEOUT_WARN) {
|
||||||
/* we had notified that they weren't responding, so now we
|
/* we had notified that they weren't responding, so now we
|
||||||
need to notify that they are again */
|
need to notify that they are again */
|
||||||
|
@ -101,16 +101,15 @@ void ping_got_pong(Time timestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it == NULL)
|
if (it == NULL)
|
||||||
ob_debug("Got PONG with timestamp %lu but not waiting for one\n",
|
ob_debug("Got PONG with id %u but not waiting for one\n", id);
|
||||||
timestamp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ping_send(ObPingTarget *t)
|
static void ping_send(ObPingTarget *t)
|
||||||
{
|
{
|
||||||
t->sent = event_get_server_time();
|
t->id = ping_next_id++;
|
||||||
/*ob_debug("PING: '%s' (timestamp %lu)\n", t->client->title, t->sent);*/
|
/*g_print("+PING: '%s' (id %u)\n", t->client->title, t->id);*/
|
||||||
PROP_MSG_TO(t->client->window, t->client->window, wm_protocols,
|
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);
|
NoEventMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,6 @@ typedef void (*ObPingEventHandler) (struct _ObClient *c, gboolean dead);
|
||||||
void ping_start(struct _ObClient *c, ObPingEventHandler h);
|
void ping_start(struct _ObClient *c, ObPingEventHandler h);
|
||||||
void ping_stop(struct _ObClient *c);
|
void ping_stop(struct _ObClient *c);
|
||||||
|
|
||||||
void ping_got_pong(Time timestamp);
|
void ping_got_pong(guint32 id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue