Skip to contentSkip to conversation

multipathd: handler fixes

PATCH New Benjamin Marzinski 1 participant 1 message May 20, 2016 Device mapper

lore
Share & tools
lore

Benjamin Marzinski

author maintainer
#0 lore raw

PATCH 1/1 multipathd: handler fixes

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.

---
 multipathd/cli.c  | 2 +-
 multipathd/main.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
multipathd/cli.c +1 -1
index d991cd0..1925d82 100644
@@ -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);
multipathd/main.c +2 -2
index 2c7486d..77c802b 100644
@@ -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);
Signature · 1 line
1.8.3.1