]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - managemon.c
ddf: Set container_member from subarray in getinfo_super.
[thirdparty/mdadm.git] / managemon.c
index 9de0c0cb41973e4c602806db4806f2d349b4264f..9b93ce4ea72c5ca08135938c23eb7bb2e131cb3a 100644 (file)
@@ -159,6 +159,7 @@ static void remove_old(void)
                if (pending_discard == discard_this)
                        pending_discard = NULL;
                discard_this = NULL;
+               wakeup_monitor();
        }
 }
 
@@ -174,7 +175,6 @@ static void replace_array(struct supertype *container,
         */
        remove_old();
        while (pending_discard) {
-               wakeup_monitor();
                while (discard_this == NULL)
                        sleep(1);
                remove_old();
@@ -428,15 +428,31 @@ void manage(struct mdstat_ent *mdstat, struct supertype *container)
        }
 }
 
-static int handle_message(struct supertype *container, struct md_message *msg)
+static void handle_message(struct supertype *container, struct metadata_update *msg)
 {
-       return -1;
+       /* queue this metadata update through to the monitor */
+
+       struct metadata_update *mu;
+
+       if (msg->len == 0) {
+               wait_update_handled();
+       } else {
+               mu = malloc(sizeof(*mu));
+               mu->len = msg->len;
+               mu->buf = msg->buf;
+               msg->buf = NULL;
+               mu->space = NULL;
+               mu->next = NULL;
+               if (container->ss->prepare_update)
+                       container->ss->prepare_update(container, mu);
+               queue_metadata_update(mu);
+       }
 }
 
 void read_sock(struct supertype *container)
 {
        int fd;
-       struct md_message msg;
+       struct metadata_update msg;
        int terminate = 0;
        long fl;
        int tmo = 3; /* 3 second timeout before hanging up the socket */
@@ -450,24 +466,16 @@ void read_sock(struct supertype *container)
        fcntl(fd, F_SETFL, fl);
 
        do {
-               int err;
-
                msg.buf = NULL;
 
                /* read and validate the message */
                if (receive_message(fd, &msg, tmo) == 0) {
-                       err = handle_message(container, &msg);
-                       if (!err)
-                               ack(fd, msg.seq, tmo);
-                       else
-                               nack(fd, err, tmo);
-               } else {
+                       handle_message(container, &msg);
+                       if (ack(fd, tmo) < 0)
+                               terminate = 1;
+               } else
                        terminate = 1;
-                       nack(fd, -1, tmo);
-               }
 
-               if (msg.buf)
-                       free(msg.buf);
        } while (!terminate);
 
        close(fd);