All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] multipathd: handler fixes
@ 2016-05-20 18:03 Benjamin Marzinski
  0 siblings, 0 replies; only message in thread
From: Benjamin Marzinski @ 2016-05-20 18:03 UTC (permalink / raw)
  To: device-mapper development; +Cc: Christophe Varoqui

We now have unlocked handlers, but these can't be used to call functions
that will access the pathvec, mpvec, or conf, since these are what the
vecs lock protects. cli_list_config and cli_list_blacklist both need to
access conf, so they can't be unlocked handlers.

Also, if parse_cmd fails to lock the vecs->lock when it calls
pthread_mutex_timedlock, we can't call unlock() on it, because unlocking
a mutex you haven't locked causes undefined behviour. So we need to
only execute the handler if didn't timeout trying to acquire the lock.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 multipathd/cli.c  | 2 +-
 multipathd/main.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/multipathd/cli.c b/multipathd/cli.c
index d991cd0..1925d82 100644
--- a/multipathd/cli.c
+++ b/multipathd/cli.c
@@ -496,7 +496,7 @@ parse_cmd (char * cmd, char ** reply, int * len, void * data, int timeout )
 			pthread_testcancel();
 			r = h->fn(cmdvec, reply, len, data);
 		}
-		lock_cleanup_pop(vecs->lock);
+		pthread_cleanup_pop(!r);
 	} else
 		r = h->fn(cmdvec, reply, len, data);
 	free_keys(cmdvec);
diff --git a/multipathd/main.c b/multipathd/main.c
index 2c7486d..77c802b 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -1132,8 +1132,8 @@ uxlsnrloop (void * ap)
 	set_handler_callback(LIST+MAP+TOPOLOGY, cli_list_map_topology);
 	set_handler_callback(LIST+MAP+FMT, cli_list_map_fmt);
 	set_handler_callback(LIST+MAP+RAW+FMT, cli_list_map_fmt);
-	set_unlocked_handler_callback(LIST+CONFIG, cli_list_config);
-	set_unlocked_handler_callback(LIST+BLACKLIST, cli_list_blacklist);
+	set_handler_callback(LIST+CONFIG, cli_list_config);
+	set_handler_callback(LIST+BLACKLIST, cli_list_blacklist);
 	set_handler_callback(LIST+DEVICES, cli_list_devices);
 	set_handler_callback(LIST+WILDCARDS, cli_list_wildcards);
 	set_handler_callback(ADD+PATH, cli_add_path);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-05-20 18:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-20 18:03 [PATCH] multipathd: handler fixes Benjamin Marzinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.