Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Messaging v3 merged: the big publish-subscribe branch of fun. #859

Merged
39 commits merged into from
Mar 27, 2019

Conversation

nmathewson
Copy link
Contributor

No description provided.

We'll be using this for four kinds of identifier in dispatch.c
You use this when you're defining a macro to be used at file scope,
and you want to require a semicolon afterwards.
We already do this in our log_debug() macro, but there are times
when we'd like to avoid allocating or precomputing something that we
are only going to log if debugging is on.
This module implements a way to send messages from one module to
another, with associated data types.  It does not yet do anything to
ensure that messages are correct, that types match, or that other
forms of consistency are preserved.
This "publish/subscribe" layer sits on top of lib/dispatch, and
tries to provide more type-safety and cross-checking for the
lower-level layer.

Even with this commit, we're still not done: more checking will come
in the next commit, and a set of usability/typesafety macros will
come after.
This code tries to prevent a large number of possible errors by
enforcing different restrictions on the messages that different
modules publish and subscribe to.

Some of these rules are probably too strict, and some too lax: we
should feel free to change them as needed as we move forward and
learn more.
When we clean up, we'd like to clear all the bindings that refer to
a dispatch_t, so that they don't have dangling pointers to it.
This commit has the necessary logic to run the publish/subscribe
system from the mainloop, and to initialize it on startup and tear
it down later.
(The header won't compile without it.)
Also, add documentation, and fix a free-on-error bug.
We want the DISPATCH_ADD_PUB() macro to count as making a
DECLARE_PUBLISH() invocation "used", so let's try a new approach
that preserves that idea.  The old one apparently did not work for
some versions of osx clang.
This is necessary to get the number of includes in main.c back under
control.  (In the future, we could just use the subsystem manager for
this kind of stuff.)
Previously, I had used integers encoded as pointers.  This
introduced a flaw: NULL represented both the integer zero, and the
absence of a setting.  This in turn made the checks in
cfg_msg_set_{type,chan}() not actually check for an altered value if
the previous value had been set to zero.

Also, I had previously kept a pointer to a dispatch_fypefns_t rather
than making a copy of it.  This meant that if the dispatch_typefns_t
were changed between defining the typefns and creating the
dispatcher, we'd get the modified version.

Found while investigating coverage in pubsub_add_{pub,sub}_()
Also fix a grammar error in a comment.
Having the numbers in those messages makes some of the unit test
unstable, by causing them to depend on the initialization order of
the naming objects.
(main.c is a bit better, but shutdown.c is ugly)
@coveralls
Copy link

Pull Request Test Coverage Report for Build 4439

  • 644 of 714 (90.2%) changed or added relevant lines in 14 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.3%) to 62.273%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/app/main/main.c 12 13 92.31%
src/lib/pubsub/pubsub_check.c 159 160 99.38%
src/lib/pubsub/pubsub_build.c 109 111 98.2%
src/lib/dispatch/dispatch_core.c 78 84 92.86%
src/app/main/subsysmgr.c 13 21 61.9%
src/app/main/shutdown.c 62 80 77.5%
src/core/mainloop/mainloop_pubsub.c 13 47 27.66%
Files with Coverage Reduction New Missed Lines %
src/core/or/relay.c 1 49.33%
Totals Coverage Status
Change from base Build 4435: 0.3%
Covered Lines: 46180
Relevant Lines: 74157

💛 - Coveralls

@ghost ghost merged commit 7b97320 into torproject:master Mar 27, 2019
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants