[multipathd] fix stop_waiter_thread() segv
authorChristophe Varoqui <root@xa-s05.(none)>
Fri, 28 Oct 2005 08:05:26 +0000 (10:05 +0200)
committerChristophe Varoqui <root@xa-s05.(none)>
Fri, 28 Oct 2005 08:05:26 +0000 (10:05 +0200)
This happened when asked to shut a waiter for a map with NULL mpp->waiter.
A code path from dm_get_maps -> setup_multipath (fails) can trigger that.

multipathd/main.c

index e56f672..bc4c1be 100644 (file)
@@ -111,11 +111,18 @@ static void
 stop_waiter_thread (struct multipath * mpp, struct vectors * vecs)
 {
        struct event_thread * wp = (struct event_thread *)mpp->waiter;
-       pthread_t thread = wp->thread;
-
-       if (!wp)
+       pthread_t thread;
+       
+       if (!wp) {
+               condlog(3, "%s: no waiter thread", mpp->alias);
                return;
+       }
+       wp = wp->thread;
 
+       if (!wp) {
+               condlog(3, "%s: thread not started", mpp->alias);
+               return;
+       }
        condlog(2, "%s: stop event checker thread", wp->mapname);
        pthread_kill(thread, SIGHUP);
 }
@@ -725,7 +732,7 @@ uev_remove_map (char * devname, struct vectors * vecs)
        if (!mpp) {
                condlog(3, "%s: devmap not registered, can't remove",
                        devname);
-               return 1;
+               return 0;
        }
 
        condlog(2, "remove %s devmap", mpp->alias);