The assert() statement in unixctl_command_register() implies that it is
intended to be idempotent but inserting the same name and callback twice
would fail because:

* The callback is not stored directly in the hash, rather it the
  cb element of a struct unixctl_command which is stored in the hash.

* Insertion would be attempted even if the entry was already present.

---

Lightly tested against 1.2.1 but targeted for master
---
 lib/unixctl.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/unixctl.c b/lib/unixctl.c
index 7cc7e5e..d75166f 100644
--- a/lib/unixctl.c
+++ b/lib/unixctl.c
@@ -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;
-- 
1.7.6.3

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to