[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-ha-dev
Subject:    [Linux-ha-dev] Re: [Linux-ha-cvs] Linux-HA CVS: heartbeat by horms from 202.221.173.98
From:       Horms <horms () verge ! net ! au>
Date:       2002-09-26 9:25:59
[Download RAW message or body]

On Thu, Sep 26, 2002 at 09:20:43AM -0000, linux-ha-cvs-admin@lists.community.tummy.com wrote:
> linux-ha CVS committal
> 
> Author  : horms
> Host    : 202.221.173.98
> Project : linux-ha
> Module  : heartbeat
> 
> Dir     : linux-ha/heartbeat
> 
> 
> Modified Files:
> 	heartbeat.c 
> 
> 
> Log Message:
> Fixed file descriptor leak in heartbeat side of heartbeat API.
> I'm not sure about ignoreing SIGPIPE, but it will do for now.

FYI

This change also included the following changes to hb_api.c.
This does not seem to have been logged to the mailing list,
probably becasue I killed my client-side cvs process halfway
through the commit.

-- 
Horms


Index: hb_api.c
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/heartbeat/hb_api.c,v
retrieving revision 1.60
diff -u -r1.60 hb_api.c
--- hb_api.c	26 Sep 2002 03:28:46 -0000	1.60
+++ hb_api.c	26 Sep 2002 09:23:37 -0000
@@ -815,7 +815,6 @@
 api_flush_msgQ(client_proc_t* client)
 {
 	const char*	fifoname;
-	int		fd;
 	int		rc;
 	int		nsig;
 	int		writeok=0;
@@ -824,24 +823,28 @@
 
 	fifoname = client_fifo_name(client, 0);
 
-	if ((fd=client->output_fifofd) < 0
-	&&	(fd=open(fifoname, O_WRONLY|O_NDELAY)) < 0) {
-		if (!client->beingremoved) {
-			/* Sometimes they've gone before we know it */
-			/* Then we get ENXIO.  So we ignore those. */
-			if (errno != ENXIO && errno != EINTR) {
-				/*
-				 * FIXME:  ???
-				 * It seems like with the O_NDELAY on the
-				 * open we ought not get EINTR.  But on
-				 * rare occasions during tests, we do anyway...
-				 * It's clearly not our fault... ;-)
-				 */
-				ha_perror("api_flush_msgQ: can't open %s"
-				,	fifoname);
-			}
-			api_remove_client(client, "FIFOerr");
+	if (client->output_fifofd < 0) {
+		client->output_fifofd = open(fifoname, O_WRONLY|O_NDELAY);
+	}
+	if(client->output_fifofd < 0) {
+		if (client->beingremoved) {
+			return;
 		}
+
+		/* Sometimes they've gone before we know it */
+		/* Then we get ENXIO.  So we ignore those. */
+		if (errno != ENXIO && errno != EINTR) {
+			/*
+			 * FIXME:  ???
+			 * It seems like with the O_NDELAY on the
+			 * open we ought not get EINTR.  But on
+			 * rare occasions during tests, we do anyway...
+			 * It's clearly not our fault... ;-)
+			 */
+			ha_perror("api_flush_msgQ: can't open %s", fifoname);
+		}
+		api_remove_client(client, "FIFOerr");
+
 		return;
 	}
 
@@ -852,7 +855,8 @@
 
 		msgstring = (char*)(client->msgQ->data);
 		msglen = strlen(msgstring);
-		if ((rc=write(fd, msgstring, msglen)) != msglen) {
+		rc=write(client->output_fifofd, msgstring, msglen);
+		if (rc != msglen) {
 			if (rc >= 0 || errno != EAGAIN) {
 				ha_perror("Cannot write message to client"
 				" %ld (write failure %d)"
@@ -861,8 +865,8 @@
 			break;
 		}
 		if (DEBUGPKTCONT) {
-			cl_log(LOG_DEBUG, "Sending message to client pid %d: msg [%s]"
-			,	client->pid, msgstring);
+			cl_log(LOG_DEBUG, "Sending message to client pid %d: "
+					"msg [%s]", client->pid, msgstring);
 		}
 
 		/* If the write succeeded, remove msg from queue */
@@ -872,15 +876,11 @@
 	}
 	nsig = (writeok ? client->signal : 0);
 
-
 	if (kill(clientpid, nsig) < 0 && errno == ESRCH) {
 		ha_log(LOG_INFO, "api_send_client: client %ld died"
 		,	(long) client->pid);
-
 		closereason = "died";
-
-	}else if (!ClientSecurityIsOK(client)) {
-
+	} else if (!ClientSecurityIsOK(client)) {
 		closereason = "security";
 	}
 
        
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.community.tummy.com
http://lists.community.tummy.com/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic