# HG changeset patch # User Paul Aurich # Date 1267242572 0 # Node ID 0d3151a41134d3c38f7fc8dd3695bfbff1a54ce3 # Parent fddded5ee51433012c4a74a3a96e9d976e3d92cb 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. diff -r fddded5ee514 -r 0d3151a41134 libpurple/protocols/jabber/jabber.c --- a/libpurple/protocols/jabber/jabber.c Fri Feb 26 14:14:43 2010 +0000 +++ b/libpurple/protocols/jabber/jabber.c Sat Feb 27 03:49:32 2010 +0000 @@ -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 *gc) { - JabberStream *js = gc->proto_data; - - if (js->keepalive_timeout == 0) { + JabberStream *js = purple_connection_get_protocol_data(gc); + time_t now = time(NULL); + + 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); diff -r fddded5ee514 -r 0d3151a41134 libpurple/protocols/jabber/jabber.h --- a/libpurple/protocols/jabber/jabber.h Fri Feb 26 14:14:43 2010 +0000 +++ b/libpurple/protocols/jabber/jabber.h Sat Feb 27 03:49:32 2010 +0000 @@ -166,6 +166,11 @@ 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;