Clean up uevent queue on shutdown
authorHannes Reinecke <hare@suse.de>
Tue, 8 Jan 2013 13:54:06 +0000 (14:54 +0100)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Tue, 8 Jan 2013 22:59:02 +0000 (23:59 +0100)
During shutdown there might be some unprocessed events
in the queue. So clear them up.

Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath/uevent.c

index b74fb08..5b0b258 100644 (file)
@@ -132,6 +132,17 @@ static void uevq_stop(void *arg)
        pthread_mutex_unlock(uevq_lockp);
 }
 
+void
+uevq_cleanup(struct list_head *tmpq)
+{
+       struct uevent *uev, *tmp;
+
+       list_for_each_entry_safe(uev, tmp, tmpq, node) {
+               list_del_init(&uev->node);
+               FREE(uev);
+       }
+}
+
 /*
  * Service the uevent queue.
  */
@@ -163,6 +174,7 @@ int uevent_dispatch(int (*uev_trigger)(struct uevent *, void * trigger_data),
                service_uevq(&uevq_tmp);
        }
        condlog(3, "Terminating uev service queue");
+       uevq_cleanup(&uevq);
        return 0;
 }