comparison libpurple/protocols/yahoo/yahoo.c @ 25015:f1de4ccc433e

Proper error handling for p2p connections
author Sulabh Mahajan <sulabh@soc.pidgin.im>
date Sat, 14 Jun 2008 08:53:43 +0000
parents 11e2d8a878b0
children d11d1ac96a0d
comparison
equal deleted inserted replaced
25014:11e2d8a878b0 25015:f1de4ccc433e
2297 struct yahoo_p2p_data *user_data; 2297 struct yahoo_p2p_data *user_data;
2298 2298
2299 if(!(user_data = data)) 2299 if(!(user_data = data))
2300 return ; 2300 return ;
2301 2301
2302 if((len = read(source, buf, sizeof(buf))) <= 0 ) { 2302 len = read(source, buf, sizeof(buf));
2303 purple_debug_warning("yahoo","p2p: Error in connection to p2p host or host disconnected\n"); 2303
2304 if ((len < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK)))
2305 return ; /* No Worries*/
2306
2307 else if (len <= 0)
2308 {
2309 purple_debug_warning("yahoo","p2p: Error in connection, or host disconnected\n");
2304 purple_input_remove(user_data->input_event); 2310 purple_input_remove(user_data->input_event);
2305 close(source); 2311 close(source);
2306 /*free user data*/ 2312 /*free user data*/
2307 g_free(user_data->host_ip); 2313 g_free(user_data->host_ip);
2308 g_free(user_data->host_username); 2314 g_free(user_data->host_username);
2309 g_free(user_data); 2315 g_free(user_data);
2310 } 2316 return;
2311 2317 }
2318
2312 if(len < YAHOO_PACKET_HDRLEN) 2319 if(len < YAHOO_PACKET_HDRLEN)
2313 return; 2320 return;
2314 2321
2315 if(strncmp((char *)buf, "YMSG", MIN(4, len)) != 0) { 2322 if(strncmp((char *)buf, "YMSG", MIN(4, len)) != 0) {
2316 /* Not a YMSG packet */ 2323 /* Not a YMSG packet */