fix mdmon takeover
authorLuca Berra <bluca@comedia.it>
Sat, 27 Feb 2010 15:07:51 +0000 (16:07 +0100)
committerNeilBrown <neilb@suse.de>
Wed, 3 Mar 2010 00:35:26 +0000 (11:35 +1100)
- when we waited for the old mdmon to exit, we didn't look
  for the socket in the right place

- when we failed to find a pid file, we returned the wrong
  value (code expected <0, but got ==0).

Signed-off-by: Luca Berra <bluca@comedia.it>
Signed-off-by: NeilBrown <neilb@suse.de>
msg.c
util.c

diff --git a/msg.c b/msg.c
index cc07b96..d2d8445 100644 (file)
--- a/msg.c
+++ b/msg.c
@@ -147,7 +147,7 @@ int connect_monitor(char *devname)
        int pos;
        char *c;
 
-       pos = sprintf(path, "%s/", VAR_RUN);
+       pos = sprintf(path, "%s/", pid_dir);
        if (is_subarray(devname)) {
                devname++;
                c = strchr(devname, '/');
diff --git a/util.c b/util.c
index 5d5711c..66be82a 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1478,11 +1478,11 @@ int mdmon_pid(int devnum)
        fd = open(path, O_RDONLY | O_NOATIME, 0);
 
        if (fd < 0)
-               return 0;
+               return -1;
        n = read(fd, pid, 9);
        close(fd);
        if (n <= 0)
-               return 0;
+               return -1;
        return atoi(pid);
 }