[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Multiple subscribers or publishers per subsystem



commit a8a0144d1183a3598bffe6c552507c9dcbdcd474
Author: Taylor Yu <catalyst@xxxxxxxxxxxxxx>
Date:   Mon Apr 1 14:53:39 2019 -0500

    Multiple subscribers or publishers per subsystem
    
    Allow a subsystem to register to publish or subscribe a given message
    from multiple places.
    
    Part of ticket 29976.
---
 src/lib/pubsub/pubsub_check.c | 26 +++++---------------------
 src/test/test_pubsub_build.c  | 43 -------------------------------------------
 2 files changed, 5 insertions(+), 64 deletions(-)

diff --git a/src/lib/pubsub/pubsub_check.c b/src/lib/pubsub/pubsub_check.c
index a3c22d4f2..bf1196df2 100644
--- a/src/lib/pubsub/pubsub_check.c
+++ b/src/lib/pubsub/pubsub_check.c
@@ -172,34 +172,20 @@ pubsub_cfg_dump(const pubsub_cfg_t *cfg, int severity, const char *prefix)
 
 /**
  * Helper: fill a bitarray <b>out</b> with entries corresponding to the
- * subsystems listed in <b>items</b>.  If any subsystem is listed more than
- * once, log a warning.  Return 0 on success, -1 on failure.
+ * subsystems listed in <b>items</b>.
  **/
-static int
+static void
 get_message_bitarray(const pubsub_adjmap_t *map,
-                     message_id_t msg,
                      const smartlist_t *items,
-                     const char *operation,
                      bitarray_t **out)
 {
-  bool ok = true;
   *out = bitarray_init_zero((unsigned)map->n_subsystems);
   if (! items)
-    return 0;
+    return;
 
   SMARTLIST_FOREACH_BEGIN(items, const pubsub_cfg_t *, cfg) {
-    if (bitarray_is_set(*out, cfg->subsys)) {
-      log_warn(LD_MESG|LD_BUG,
-               "Message \"%s\" is configured to be %s by subsystem "
-               "\"%s\" more than once.",
-               get_message_id_name(msg), operation,
-               get_subsys_id_name(cfg->subsys));
-      ok = false;
-    }
     bitarray_set(*out, cfg->subsys);
   } SMARTLIST_FOREACH_END(cfg);
-
-  return ok ? 0 : -1;
 }
 
 /**
@@ -222,10 +208,8 @@ lint_message_graph(const pubsub_adjmap_t *map,
   bitarray_t *subscribed_by = NULL;
   bool ok = true;
 
-  if (get_message_bitarray(map, msg, pub, "published", &published_by) < 0)
-    ok = false;
-  if (get_message_bitarray(map, msg, sub, "subscribed", &subscribed_by) < 0)
-    ok = false;
+  get_message_bitarray(map, pub, &published_by);
+  get_message_bitarray(map, sub, &subscribed_by);
 
   /* Check whether any subsystem is publishing and subscribing the same
    * message. [??]
diff --git a/src/test/test_pubsub_build.c b/src/test/test_pubsub_build.c
index ce5bf6008..021323fbf 100644
--- a/src/test/test_pubsub_build.c
+++ b/src/test/test_pubsub_build.c
@@ -493,48 +493,6 @@ test_pubsub_build_sub_many(void *arg)
   tor_free(sysname);
 }
 
-/* The same subsystem can only declare one publish or subscribe. */
-static void
-test_pubsub_build_pubsub_redundant(void *arg)
-{
-  (void)arg;
-  pubsub_builder_t *b = NULL;
-  dispatch_t *dispatcher = NULL;
-  pubsub_connector_t *c = NULL;
-
-  b = pubsub_builder_new();
-  seed_pubsub_builder_basic(b);
-  pub_binding_t btmp;
-
-  {
-    c = pubsub_connector_for_subsystem(b, get_subsys_id("sys2"));
-    DISPATCH_ADD_SUB(c, main, bunch_of_coconuts);
-    pubsub_add_pub_(c, &btmp, get_channel_id("main"),
-                    get_message_id("yes_we_have_no"),
-                    get_msg_type_id("string"),
-                    0 /* flags */,
-                    "somewhere.c", 22);
-    pubsub_connector_free(c);
-  };
-
-  setup_full_capture_of_logs(LOG_WARN);
-  dispatcher = pubsub_builder_finalize(b, NULL);
-  b = NULL;
-  tt_assert(dispatcher == NULL);
-
-  expect_log_msg_containing(
-    "Message \"yes_we_have_no\" is configured to be published by "
-    "subsystem \"sys2\" more than once.");
-  expect_log_msg_containing(
-    "Message \"bunch_of_coconuts\" is configured to be subscribed by "
-    "subsystem \"sys2\" more than once.");
-
- done:
-  pubsub_builder_free(b);
-  dispatch_free(dispatcher);
-  teardown_capture_of_logs();
-}
-
 /* It's fine to declare the excl flag. */
 static void
 test_pubsub_build_excl_ok(void *arg)
@@ -614,7 +572,6 @@ struct testcase_t pubsub_build_tests[] = {
   T(pubsub_same, TT_FORK),
   T(pubsub_multi, TT_FORK),
   T(sub_many, TT_FORK),
-  T(pubsub_redundant, TT_FORK),
   T(excl_ok, TT_FORK),
   T(excl_bad, TT_FORK),
   END_OF_TESTCASES



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits