pidgin: 43ae15bb: jabber: Don't ping more often than once ...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Fri Feb 26 23:10:38 EST 2010
-----------------------------------------------------------------
Revision: 43ae15bb3b5dce0516c4f3da6efc5f7b7a88868d
Ancestor: cb951ec870fc6aba8a3f45fb58514b55babec109
Author: darkrain42 at pidgin.im
Date: 2010-02-27T03:49:32
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/43ae15bb3b5dce0516c4f3da6efc5f7b7a88868d
Modified files:
libpurple/protocols/jabber/jabber.c
libpurple/protocols/jabber/jabber.h
ChangeLog:
jabber: Don't ping more often than once a minute.
>From rfc3920bis:
The length
of time between the use of any particular connection test is a matter
of implementation and local service policy; however, it is
RECOMMENDED that any such test be performed not more than once every
60 seconds.
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jabber.c 2c20a5962cfa46bf9e8bab02eb43a63df60ebc9e
+++ libpurple/protocols/jabber/jabber.c a05f6c1749aea060c23989e18eb8a8202c832f17
@@ -70,6 +70,8 @@
#include "jingle/jingle.h"
#include "jingle/rtp.h"
+#define PING_TIMEOUT 60
+
GList *jabber_features = NULL;
GList *jabber_identities = NULL;
static GSList *jabber_cmds = NULL;
@@ -521,9 +523,12 @@ void jabber_keepalive(PurpleConnection *
void jabber_keepalive(PurpleConnection *gc)
{
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
+ time_t now = time(NULL);
- if (js->keepalive_timeout == 0) {
+ if (js->keepalive_timeout == 0 && (now - js->last_ping) >= PING_TIMEOUT) {
+ js->last_ping = now;
+
jabber_keepalive_ping(js);
js->keepalive_timeout = purple_timeout_add_seconds(120,
(GSourceFunc)(jabber_keepalive_timeout), gc);
============================================================
--- libpurple/protocols/jabber/jabber.h ecb6d7836f1d4b28d2919396859ca51a6842a931
+++ libpurple/protocols/jabber/jabber.h 0e6e98982a3b5fab363175e68fd2a1bef72df2e8
@@ -166,6 +166,11 @@ struct _JabberStream
time_t idle;
time_t old_idle;
+ /** When we last pinged the server, so we don't ping more
+ * often than once every minute.
+ */
+ time_t last_ping;
+
JabberID *user;
JabberBuddy *user_jb;
More information about the Commits
mailing list