RHEL4 - rgmanager: Fix file descriptor leak caused by some events

Lon Hohberger lon@fedoraproject.org
Thu Sep 11 18:56:00 GMT 2008


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=12a7b076984a5e92a4c2f4fc6d589f75e6d7b646
Commit:        12a7b076984a5e92a4c2f4fc6d589f75e6d7b646
Parent:        9538102331f90bc086329ffb50af82605c6716f4
Author:        Lon Hohberger <lhh@redhat.com>
AuthorDate:    Thu Sep 11 12:47:20 2008 -0400
Committer:     Lon Hohberger <lhh@redhat.com>
CommitterDate: Thu Sep 11 12:53:55 2008 -0400

rgmanager: Fix file descriptor leak caused by some events

rhbz#461954
---
 rgmanager/src/daemons/main.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/rgmanager/src/daemons/main.c b/rgmanager/src/daemons/main.c
index 07fe206..05997aa 100644
--- a/rgmanager/src/daemons/main.c
+++ b/rgmanager/src/daemons/main.c
@@ -308,6 +308,7 @@ dispatch_msg(int fd, uint64_t nodeid)
 	ret = msg_peek(fd, &msg_hdr, sizeof(msg_hdr));
 	if (ret != sizeof (generic_msg_hdr)) {
 		clulog(LOG_ERR, "#37: Error receiving message header\n");
+		msg_close(fd);
 		return -1;
 	}
 
@@ -317,6 +318,7 @@ dispatch_msg(int fd, uint64_t nodeid)
 		clulog(LOG_ERR,
 		       "#38: Invalid magic: Wanted 0x%08x, got 0x%08x\n",
 		       GENERIC_HDR_MAGIC, msg_hdr.gh_magic);
+		msg_close(fd);
 		return -1;
 	}
 
@@ -362,6 +364,7 @@ dispatch_msg(int fd, uint64_t nodeid)
 		if (ret != sizeof(msg_sm)) {
 			clulog(LOG_ERR,
 			       "#39: Error receiving entire request\n");
+			msg_close(fd);
 			return -1;
 		}
 
@@ -420,7 +423,7 @@ dispatch_msg(int fd, uint64_t nodeid)
 			clulog(LOG_ERR,
 			       "#39: Error receiving entire request (%d/%d)\n",
 			       ret, (int)sizeof(rg_state_msg_t));
-			ret = -1;
+			msg_close(fd);
 			break;
 		}
 
@@ -432,6 +435,8 @@ dispatch_msg(int fd, uint64_t nodeid)
 			   msg_rsm.rsm_state.rs_state,
 			   msg_rsm.rsm_state.rs_owner,
 			   msg_rsm.rsm_state.rs_last_owner);
+
+		msg_close(fd);
 		break;
 
 	case RG_EXITING:
@@ -450,6 +455,7 @@ dispatch_msg(int fd, uint64_t nodeid)
 	default:
 		clulog(LOG_DEBUG, "unhandled message request %d\n",
 		       msg_hdr.gh_command);
+		msg_close(fd);
 		break;
 	}
 	return 0;



More information about the Cluster-cvs mailing list