soc.2008.yahoo: c1d570c1: Close p2p connection when read() does no...
sulabh at soc.pidgin.im
sulabh at soc.pidgin.im
Fri Jun 13 07:10:42 EDT 2008
-----------------------------------------------------------------
Revision: c1d570c12e7615d03450db53705eec4241f6ec3e
Ancestor: 04876058ae13979567ccdd392c700c86048c425b
Author: sulabh at soc.pidgin.im
Date: 2008-06-13T11:04:13
Branch: im.pidgin.soc.2008.yahoo
URL: http://d.pidgin.im/viewmtn/revision/info/c1d570c12e7615d03450db53705eec4241f6ec3e
Modified files:
libpurple/protocols/yahoo/yahoo.c
libpurple/protocols/yahoo/yahoo.h
ChangeLog:
Close p2p connection when read() does not return anything.
-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/yahoo.c 180c4f1222d2a3c3b9eeff302bad33241f440054
+++ libpurple/protocols/yahoo/yahoo.c 6f23514b2a526d31f29265b0fdb23ba48b163395
@@ -246,7 +246,7 @@ static void yahoo_process_status(PurpleC
if (f->away == 2) {
/* Idle may have already been set in a more precise way in case 137 */
if (f->idle == 0)
- f->idle = time(NULL);
+ f->idle = time(NULL) - 60; /*start idle at 1 min*/
}
break;
@@ -2296,13 +2296,22 @@ static void yahoo_p2p_read_pkt_cb(gpoint
guchar *start = NULL;
struct yahoo_p2p_data *user_data;
- user_data = data;
+ if(!(user_data = data))
+ return ;
- if((len = read(source, buf, sizeof(buf))) <= 0 )
- purple_debug_warning("yahoo","p2p: Error in connection to p2p host\n");
+ if((len = read(source, buf, sizeof(buf))) <= 0 ) {
+ purple_debug_warning("yahoo","p2p: Error in connection to p2p host or host disconnected\n");
+ purple_input_remove(user_data->input_event);
+ close(source);
+ /*free user data*/
+ g_free(user_data->host_ip);
+ g_free(user_data->host_username);
+ g_free(user_data);
+ }
if(len < YAHOO_PACKET_HDRLEN)
return;
+
if(strncmp((char *)buf, "YMSG", MIN(4, len)) != 0) {
/* Not a YMSG packet */
purple_debug_warning("yahoo","p2p: Got something other than YMSG packet\n");
@@ -2361,12 +2370,12 @@ static void yahoo_p2p_init_cb(gpointer d
purple_debug_warning("yahoo","p2p: %s\n",error_message);
return;
}
- /*Add an Input Read event to the file descriptor*/
- purple_input_add(source, PURPLE_INPUT_READ, yahoo_p2p_read_pkt_cb, data);
-
if(!(user_data = data))
return ;
+ /*Add an Input Read event to the file descriptor*/
+ user_data->input_event = purple_input_add(source, PURPLE_INPUT_READ, yahoo_p2p_read_pkt_cb, data);
+
account = purple_connection_get_account(user_data->gc);
/*Build the yahoo packet*/
============================================================
--- libpurple/protocols/yahoo/yahoo.h 585896e01804f3595b6238019acb61b25662cc4f
+++ libpurple/protocols/yahoo/yahoo.h c2958fa17023ac0e0ae69533b271f7621bb177db
@@ -120,6 +120,7 @@ struct yahoo_p2p_data {
int session_id;
char *host_username;
int val_13;
+ guint input_event;
};
struct _YchtConn;
More information about the Commits
mailing list