diff libpurple/protocols/jabber/jabber.c @ 29889:0d3151a41134

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.
author Paul Aurich <paul@darkrain42.org>
date Sat, 27 Feb 2010 03:49:32 +0000
parents 185677f47825
children 08ceb05e9fe9 7adebf6acc50
line wrap: on
line diff
--- 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);