summaryrefslogtreecommitdiff
path: root/mdmon.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2011-11-07 11:44:21 +1100
committerNeilBrown <neilb@suse.de>2011-11-07 11:44:21 +1100
commit88e5516ea914f0e9d433a50dc0b2867085250308 (patch)
tree172c26daa1883cf349b0b80ba68d79b1891575f4 /mdmon.c
parent84a230d993d6a953876f3b83ae79ed519ebf4d07 (diff)
mdmon: avoid using victim_sock when it is -1.
It possible that we try to use victim_sock even when we couldn't open it. This is never actually harmful but it looks wrong and it is best to fix it. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mdmon.c')
-rw-r--r--mdmon.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/mdmon.c b/mdmon.c
index ee68e3c3..b6ae0e68 100644
--- a/mdmon.c
+++ b/mdmon.c
@@ -189,6 +189,9 @@ static void try_kill_monitor(pid_t pid, char *devname, int sock)
kill(pid, SIGTERM);
+ if (sock < 0)
+ return;
+
/* Wait for monitor to exit by reading from the socket, after
* clearing the non-blocking flag */
fl = fcntl(sock, F_GETFL, 0);
@@ -468,6 +471,7 @@ static int mdmon(char *devname, int devnum, int must_fork, int takeover)
exit(3);
}
close(victim_sock);
+ victim_sock = -1;
}
if (container->ss->load_container(container, mdfd, devname)) {
fprintf(stderr, "mdmon: Cannot load metadata for %s\n",
@@ -501,7 +505,8 @@ static int mdmon(char *devname, int devnum, int must_fork, int takeover)
if (victim > 0) {
try_kill_monitor(victim, container->devname, victim_sock);
- close(victim_sock);
+ if (victim_sock >= 0)
+ close(victim_sock);
}
setsid();