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

Log dependencies #174

Merged
merged 36 commits into from Jun 26, 2018
Merged

Log dependencies #174

merged 36 commits into from Jun 26, 2018

Conversation

Labels
None yet
Projects
None yet
5 participants
@nmathewson
Copy link
Contributor

@nmathewson nmathewson commented Jun 22, 2018

No description provided.

nmathewson added 30 commits Jun 21, 2018
Minimizing includes revealed other places includes were necessary.
Containers were using crypto_digest.h, just to see the value of
DIGEST_LEN.  Moved those constants into a new defs module.
Now that I know that "strings" nests below "container", I know this
is safe.
The locking code gets its own module, since it's more fundamental
than the higher-level locking code.

Extracting the logging code was the whole point here. :)
This change makes a whole bunch of things in torlog.c break, since
apparently I did not find all the fd dependencies.
This patch:
  - introduces an fdio module for low-level fd functions that don't
    need to log.
  - moves the responsibility for opening files outside of torlog.c,
    so it won't need to call tor_open_cloexec.
@coveralls
Copy link

@coveralls coveralls commented Jun 22, 2018

Coverage Status

Coverage decreased (-0.03%) to 59.862% when pulling 1b93b06 on nmathewson:log_dependencies into eb784aa on torproject:master.

@teor2345
Copy link
Contributor

@teor2345 teor2345 commented Jun 25, 2018

What's the trac ticket here?

@@ -23,6 +23,7 @@
#include <sys/stat.h>
#endif
#include "lib/err/torerr.h"
#include "lib/malloc/util_malloc.h"
Copy link
Contributor

@dgoulet-tor dgoulet-tor Jun 26, 2018

I'll bikeshed here but I think util.h or even malloc.h (I might personally prefer util.h) could be better here because we are already in the "malloc module" so util_malloc.h when we enforce the lib/malloc/ include statement is redundant.

Copy link
Contributor Author

@nmathewson nmathewson Jun 26, 2018

I think malloc.h is fine, but not util.h -- that would mean we had a bunch of files named util.h, and I don't want to have two headers or c files with the same name.

* with helper functions to use smartlists. Also includes
* hash table implementations of a string-to-void* map, and of
* a digest-to-void* map.
**/
Copy link
Contributor

@dgoulet-tor dgoulet-tor Jun 26, 2018

This whole section is wrong.

int mask; /**< One less than the number of bits in <b>ba</b>; always one less
* than a power of two. */
bitarray_t *ba; /**< A bit array to implement the Bloom filter. */
} digestset_t;
Copy link
Contributor

@dgoulet-tor dgoulet-tor Jun 26, 2018

I think, this can be done after, we should namespace these with the bloomfilt name even thought "digest set" is technically valid.

* with helper functions to use smartlists. Also includes
* hash table implementations of a string-to-void* map, and of
* a digest-to-void* map.
**/
Copy link
Contributor

@dgoulet-tor dgoulet-tor Jun 26, 2018

Bad comments, I guess copy pasting :). Seems many files in lib/container/ suffer from this.

src/include.am Outdated
@@ -5,6 +5,7 @@ include src/lib/ctime/include.am
include src/lib/compress/include.am
include src/lib/container/include.am
include src/lib/crypt_ops/include.am
include src/lib/defs/include.am
Copy link
Contributor

@dgoulet-tor dgoulet-tor Jun 26, 2018

What does defs/ stands for here? "Definitions" I presume? Would we put all global constant in there or ?...

Copy link
Contributor Author

@nmathewson nmathewson Jun 26, 2018

yes, definitions. But I think only top-level definitions that need to be really global.


src_lib_libtor_string_a_SOURCES = \
src/lib/string/compat_ctype.c \
src/lib/string/util_string.c \
Copy link
Contributor

@dgoulet-tor dgoulet-tor Jun 26, 2018

I might have the same comment as malloc module here with this util_string.c.

.gitignore Outdated
@@ -173,6 +173,8 @@ uptime-*.json
/src/lib/libtor-ctime-testing.a
/src/lib/libtor-err.a
/src/lib/libtor-err-testing.a
/src/lib/libtor-intmath.a
Copy link
Contributor

@dgoulet-tor dgoulet-tor Jun 26, 2018

What about a math module instead and we put everything related to "math" in there (not only int stuff). I mean with this name, does the floating math functions apply to go in?

Copy link
Contributor Author

@nmathewson nmathewson Jun 26, 2018

no, higher-level stuff should go in another module.

This one is for low-level integer math.

@@ -7,6 +7,7 @@ endif

src_lib_libtor_wallclock_a_SOURCES = \
src/lib/wallclock/approx_time.c \
src/lib/wallclock/tm_cvt.c \
Copy link
Contributor

@dgoulet-tor dgoulet-tor Jun 26, 2018

I'm not familiar with this naming, what does tm_cvt means here?

Copy link
Contributor Author

@nmathewson nmathewson Jun 26, 2018

tm is "struct tm"; cvt is convert.

Makefile.am Outdated
@@ -42,6 +42,7 @@ TOR_UTIL_LIBS = \
src/common/libor.a \
src/lib/libtor-log.a \
src/lib/libtor-lock.a \
src/lib/libtor-fdio.a \
Copy link
Contributor

@dgoulet-tor dgoulet-tor Jun 26, 2018

Quick question: Is the goal of this library to also get the tor_open_* family of functions (currently mostly in compat.c)?

If yes, I'm wondering if libtor-io.a wouldn't be better and we could also bring in all the network low level functions? Or for that you had in mind a libtor-network. kind of separation?

Copy link
Contributor Author

@nmathewson nmathewson Jun 26, 2018

No, tor_open_* needs to be at a higher level, or else it will cause a circular dependency. Those functions have a lot of complexity, and have the potential to log, and require the sandbox code.

@tor-bot tor-bot merged commit 1b93b06 into torproject:master Jun 26, 2018
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment