summaryrefslogtreecommitdiff
path: root/src/lib/compress/compress.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-11-02 18:34:56 -0400
committerNick Mathewson <nickm@torproject.org>2018-11-05 09:22:02 -0500
commit019a044e5e6586fb42a171cb98aea15a72bd5a13 (patch)
treeecef2a3f24eeed94effaad245b649aff1a50e46a /src/lib/compress/compress.c
parent207253df8d7c040840c7f4305534e6979bfc7bf7 (diff)
downloadtor-019a044e5e6586fb42a171cb98aea15a72bd5a13.tar.gz
tor-019a044e5e6586fb42a171cb98aea15a72bd5a13.zip
Turn "compress" into a subsystem.
Diffstat (limited to 'src/lib/compress/compress.c')
-rw-r--r--src/lib/compress/compress.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/lib/compress/compress.c b/src/lib/compress/compress.c
index 2ad9b15b2e..0d134fd1be 100644
--- a/src/lib/compress/compress.c
+++ b/src/lib/compress/compress.c
@@ -29,10 +29,12 @@
#include "lib/compress/compress.h"
#include "lib/compress/compress_lzma.h"
#include "lib/compress/compress_none.h"
+#include "lib/compress/compress_sys.h"
#include "lib/compress/compress_zlib.h"
#include "lib/compress/compress_zstd.h"
#include "lib/intmath/cmp.h"
#include "lib/malloc/malloc.h"
+#include "lib/subsys/subsys.h"
#include "lib/thread/threads.h"
/** Total number of bytes allocated for compression state overhead. */
@@ -660,7 +662,7 @@ tor_compress_state_size(const tor_compress_state_t *state)
}
/** Initialize all compression modules. */
-void
+int
tor_compress_init(void)
{
atomic_counter_init(&total_compress_allocation);
@@ -668,6 +670,8 @@ tor_compress_init(void)
tor_zlib_init();
tor_lzma_init();
tor_zstd_init();
+
+ return 0;
}
/** Warn if we had any problems while setting up our compression libraries.
@@ -677,5 +681,14 @@ tor_compress_init(void)
void
tor_compress_log_init_warnings(void)
{
+ // XXXX can we move this into tor_compress_init() after all? log.c queues
+ // XXXX log messages at startup.
tor_zstd_warn_if_version_mismatched();
}
+
+const subsys_fns_t sys_compress = {
+ .name = "compress",
+ .supported = true,
+ .level = -70,
+ .initialize = tor_compress_init,
+};