Mercurial > pidgin.yaz
diff libpurple/connection.c @ 22149:252b96b6a32c
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Wed, 23 Jan 2008 23:28:38 +0000 |
parents | 7553cbc95504 |
children | fbdf8136c98c |
line wrap: on
line diff
--- a/libpurple/connection.c Thu Jan 17 21:08:20 2008 +0000 +++ b/libpurple/connection.c Wed Jan 23 23:28:38 2008 +0000 @@ -52,8 +52,19 @@ 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);