[mw-devel] MW3 r1061 - trunk/src

firefury at sucs.org firefury at sucs.org
Fri Jan 9 10:01:47 GMT 2009


Author: firefury
Date: 2009-01-09 10:01:47 +0000 (Fri, 09 Jan 2009)
New Revision: 1061

Modified:
   trunk/src/ipc.c
Log:
Fix socket descriptor leak when a write() to a FIFO fails


Modified: trunk/src/ipc.c
===================================================================
--- trunk/src/ipc.c	2008-11-08 18:27:18 UTC (rev 1060)
+++ trunk/src/ipc.c	2009-01-09 10:01:47 UTC (rev 1061)
@@ -31,6 +31,7 @@
 	ssize_t	dgram_len;
 	pid_t	mypid;
 	char *	qdata;
+	int	ret = 0;
 
 	if (dest < 1) return -1;	// Invalid PID
 	if (! data) data = "";
@@ -57,14 +58,14 @@
 			dgram_len = strlen(buff+5)+5;
 			if (write(fd, buff, dgram_len) <= 0) {
 				//fprintf(stderr, "Write to %s failed: %s\n", fifo_path, strerror(errno));
-				return -2;
+				ret = -2;
 			}
 		} else {
 			fprintf(stderr, "Failed to utf8_clean the message to, %s (not sent)\n", fifo_path); 
 		}
 	}
 	close(fd);
-	return 0;
+	return ret;
 }
 
 /*





More information about the mw-devel mailing list