[vhffs-dev] [1262] Fixed segfault when a connection disappear will sending data

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1262
Author:   gradator
Date:     2008-10-07 01:21:31 +0200 (Tue, 07 Oct 2008)

Log Message:
-----------
Fixed segfault when a connection disappear will sending data

Modified Paths:
--------------
    trunk/vhffs-fssync/getevents.c


Modified: trunk/vhffs-fssync/getevents.c
===================================================================
--- trunk/vhffs-fssync/getevents.c	2008-10-06 22:55:19 UTC (rev 1261)
+++ trunk/vhffs-fssync/getevents.c	2008-10-06 23:21:31 UTC (rev 1262)
@@ -424,12 +424,12 @@
 	GList *msgs;
 	gboolean full = FALSE;
 
-	if(conn->fd < 0) return -1;
+	if(!conn || conn->fd < 0) return -1;
 #if DEBUG_NET
 	printf("--------------------------------------------------\n");
 	printf("conn: %d, to: %s\n", conn->fd, inet_ntoa(conn->sockaddr.sin_addr));
 #endif
-	while(!full  &&  (msgs = g_list_first(conn->messages)) )  {
+	while(!full  &&  conn  &&  (msgs = g_list_first(conn->messages)) )  {
 		coucou_net_message *msg = msgs->data;
 #if DEBUG_NET
  		printf("  family: %d , priority: %d , order: %d\n", msg->msg_family, msg->msg_priority, msg->msg_order);
@@ -462,6 +462,7 @@
 					default:
 						fprintf(stderr, "write() failed on socket fd: %s\n", strerror(errno));
 						coucou_net_conn_destroy(conn);
+						conn = NULL;
 				}
 			}
 			else {
@@ -527,6 +528,7 @@
 					default:
 						fprintf(stderr, "sendfile() failed from file %s to socket: %s\n", filemsg->file_pathname, strerror(errno));
 						coucou_net_conn_destroy(conn);
+						conn = NULL;
 				}
 			}
 			else {


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/