Make unixctl_command_register() idempotent
[sliver-openvswitch.git] / lib / unixctl.c
index 7cc7e5e..d75166f 100644 (file)
@@ -115,9 +115,14 @@ unixctl_command_register(const char *name, const char *args,
         unixctl_cb_func *cb, void *aux)
 {
     struct unixctl_command *command;
+    struct unixctl_command *lookup = shash_find_data(&commands, name);
+
+    assert(!lookup || lookup->cb == cb);
+
+    if (lookup) {
+        return;
+    }
 
-    assert(!shash_find_data(&commands, name)
-           || shash_find_data(&commands, name) == cb);
     command = xmalloc(sizeof *command);
     command->args = args;
     command->cb = cb;