im.pidgin.pidgin: a0479b7ebd8713b6442fb2ecb8238b7e71be61b5
seanegan at pidgin.im
seanegan at pidgin.im
Thu Jan 24 19:56:13 EST 2008
-----------------------------------------------------------------
Revision: a0479b7ebd8713b6442fb2ecb8238b7e71be61b5
Ancestor: e710412b710c5694a04ad40e4922f33f6471b559
Author: seanegan at pidgin.im
Date: 2008-01-23T23:28:38
Branch: im.pidgin.pidgin
Modified files:
ChangeLog.API libpurple/connection.c libpurple/connection.h
libpurple/protocols/gg/gg.c libpurple/protocols/irc/irc.c
libpurple/protocols/jabber/jabber.c
libpurple/protocols/msn/servconn.c
libpurple/protocols/msnp9/servconn.c
libpurple/protocols/myspace/myspace.c
libpurple/protocols/oscar/flap_connection.c
libpurple/protocols/sametime/sametime.c
libpurple/protocols/simple/simple.c
libpurple/protocols/yahoo/yahoo.c
ChangeLog:
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
-------------- next part --------------
============================================================
--- ChangeLog.API a5a3c86dbafbd51b09a61561a351b55dcb6b0614
+++ ChangeLog.API 68320d2fdaf96e3ea45300ef96b9b83cc93b74c4
@@ -30,6 +30,8 @@ version 2.4.0 (??/??/????):
* purple_attention_type_get_outgoing_desc
* purple_attention_type_get_icon_name
* purple_attention_type_get_unlocalized_name
+ * last_received to PurpleAccount, the time_t of the last
+ received packet
Pidgin:
Added:
============================================================
--- libpurple/connection.c c02ce003fec3d591c07f75c56fcaa406ff9dd78c
+++ libpurple/connection.c 01709808d302c2b71d1db45623047337cd7a2487
@@ -52,9 +52,20 @@ send_keepalive(gpointer data)
PurpleConnection *gc = data;
PurplePluginProtocolInfo *prpl_info = NULL;
- if (gc != NULL && gc->prpl != NULL)
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
+ if (gc == NULL)
+ return;
+ /* Only send keep-alives if we haven't heard from the
+ * server in a while.
+ */
+ if ((time(NULL) - gc->last_received) < KEEPALIVE_INTERVAL)
+ return;
+
+ if (gc->prpl == NULL)
+ return;
+
+ prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
+
if (prpl_info && prpl_info->keepalive)
prpl_info->keepalive(gc);
============================================================
--- libpurple/connection.h db7e189d3c532eb1301fa44752bdf6af5dae6ea1
+++ libpurple/connection.h c047a7173fe3e6f351c00be7b2f37a0345ee7413
@@ -251,6 +251,8 @@ struct _PurpleConnection
gboolean wants_to_die;
guint disconnect_timeout; /**< Timer used for nasty stack tricks */
+ time_t last_received; /**< When we last received a packet. Set by the
+ prpl to avoid sending unneeded keepalives */
};
#ifdef __cplusplus
============================================================
--- libpurple/protocols/gg/gg.c 65e9b321458489ed42734be652b26386077d34c8
+++ libpurple/protocols/gg/gg.c 62e71da48e1afcb4f730b16c6eefbbeec41cabd0
@@ -1314,7 +1314,7 @@ static void ggp_callback_recv(gpointer _
_("Unable to read socket"));
return;
}
-
+ gc->last_received = time(NULL);
switch (ev->type) {
case GG_EVENT_NONE:
/* Nothing happened. */
============================================================
--- libpurple/protocols/irc/irc.c a54326ee583fcd7b7cfe461cc96eff8003dc50f3
+++ libpurple/protocols/irc/irc.c 123ab56826fab72d4e46f7dfdc7b0d385e4e61e0
@@ -572,6 +572,7 @@ static void read_input(struct irc_conn *
{
char *cur, *end;
+ irc->account->gc->last_received = time(NULL);
irc->inbufused += len;
irc->inbuf[irc->inbufused] = '\0';
============================================================
--- libpurple/protocols/jabber/jabber.c d3e6608f911b2932fed29470935404cf5e007819
+++ libpurple/protocols/jabber/jabber.c adf0280fc2a535cd4b4bf37cd04a0e9e8c558c16
@@ -432,6 +432,7 @@ jabber_recv_cb_ssl(gpointer data, Purple
}
while((len = purple_ssl_read(gsc, buf, sizeof(buf) - 1)) > 0) {
+ gc->last_received = time(NULL);
buf[len] = '\0';
purple_debug(PURPLE_DEBUG_INFO, "jabber", "Recv (ssl)(%d): %s\n", len, buf);
jabber_parser_process(js, buf, len);
@@ -459,6 +460,7 @@ jabber_recv_cb(gpointer data, gint sourc
return;
if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) {
+ gc->last_received = time(NULL);
#ifdef HAVE_CYRUS_SASL
if (js->sasl_maxbuf>0) {
const char *out;
============================================================
--- libpurple/protocols/msn/servconn.c a404db10b492bc719f40a4f19f2af1690efa7e8b
+++ libpurple/protocols/msn/servconn.c b5de5d3a36003f9f7b20c326a8dfec0c1f223de2
@@ -391,6 +391,7 @@ read_cb(gpointer data, gint source, Purp
session = servconn->session;
len = read(servconn->fd, buf, sizeof(buf) - 1);
+ servconn->session->account->gc->last_connected = time(NULL);
if (len <= 0) {
switch (errno) {
============================================================
--- libpurple/protocols/msnp9/servconn.c a28c3675abee433b4bc90382be2d29f92f068b76
+++ libpurple/protocols/msnp9/servconn.c b9f1ecd45bd42e69acf0a9b576c6befe445dee66
@@ -387,6 +387,7 @@ read_cb(gpointer data, gint source, Purp
session = servconn->session;
len = read(servconn->fd, buf, sizeof(buf) - 1);
+ servconn->session->account->gc->last_received = time(NULL);
if (len < 0 && errno == EAGAIN)
return;
============================================================
--- libpurple/protocols/myspace/myspace.c 05c7086a97082f4c49b014e0eeb35e30545d4591
+++ libpurple/protocols/myspace/myspace.c 6719a9f6a924985d181987505697df317ea975b5
@@ -2452,6 +2452,7 @@ msim_input_cb(gpointer gc_uncasted, gint
* the file descriptor, but it sometimes differs from the 'source' parameter.
*/
n = recv(session->fd, session->rxbuf + session->rxoff, MSIM_READ_BUF_SIZE - session->rxoff, 0);
+ gc->last_received = time(NULL);
if (n < 0 && errno == EAGAIN) {
return;
============================================================
--- libpurple/protocols/oscar/flap_connection.c b3c9d505d8cd6772ff3d3ea77d62e0202cf0eb00
+++ libpurple/protocols/oscar/flap_connection.c 8bb1e373be31cd238f3a026597d00f62cd3f731d
@@ -817,6 +817,7 @@ flap_connection_recv_cb(gpointer data, g
OSCAR_DISCONNECT_LOST_CONNECTION, g_strerror(errno));
break;
}
+ conn->od->gc->last_received = time(NULL);
/* If we don't even have a complete FLAP header then do nothing */
conn->header_received += read;
============================================================
--- libpurple/protocols/sametime/sametime.c 4852c37f073cfb87939f912c1a78464be4adc2df
+++ libpurple/protocols/sametime/sametime.c a7cc50e00c6137944213bdf41474ec8e5ac494f4
@@ -1695,7 +1695,9 @@ static int read_recv(struct mwSession *s
int len;
len = read(sock, buf, BUF_LEN);
- if(len > 0) mwSession_recv(session, buf, len);
+ if(len > 0) {
+ mwSession_recv(session, buf, len);
+ }
return len;
}
============================================================
--- libpurple/protocols/simple/simple.c 0b410fae2296d2dff79e4f7495cac1217e766259
+++ libpurple/protocols/simple/simple.c 550bf26db8a28bc30f45e86aa3527dc91403c2f9
@@ -1675,7 +1675,7 @@ static void simple_input_cb(gpointer dat
if(sip->fd == source) sip->fd = -1;
return;
}
-
+ gc->last_received = time(NULL);
conn->inbufused += len;
conn->inbuf[conn->inbufused] = '\0';
============================================================
--- libpurple/protocols/yahoo/yahoo.c 839c14fedd61f40c26a89ae8a1a0f119b4a5cfca
+++ libpurple/protocols/yahoo/yahoo.c a228d6e32bc131ceb6f315d5bb5b8d9c7d8551e1
@@ -2506,7 +2506,7 @@ static void yahoo_pending(gpointer data,
_("Server closed the connection."));
return;
}
-
+ gc->last_received = time(NULL);
yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen);
memcpy(yd->rxqueue + yd->rxlen, buf, len);
yd->rxlen += len;
More information about the Commits
mailing list