From f90b987218d3bfe242b2917fc4acdd5db394ea47 Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Mon, 24 Oct 2022 14:36:48 -0400 Subject: [PATCH] Add a Db to the matrixArgs so that routes can access it. --- src/Telodendria.c | 16 ++++++++++++++++ src/include/Matrix.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/src/Telodendria.c b/src/Telodendria.c index 8b3c38e..f11407e 100644 --- a/src/Telodendria.c +++ b/src/Telodendria.c @@ -38,6 +38,7 @@ #include #include #include +#include static void TelodendriaMemoryHook(MemoryAction a, MemoryInfo * i, void *args) @@ -418,6 +419,20 @@ main(int argc, char **argv) tConfig->uid = NULL; tConfig->gid = NULL; + matrixArgs.db = DbOpen(".", tConfig->maxCache); + + if (!tConfig->maxCache) + { + Log(lc, LOG_WARNING, "Max-cache is set to zero; caching is disabled."); + } + + if (!matrixArgs.db) + { + Log(lc, LOG_ERROR, "Unable to open data directory as a database."); + exit = EXIT_FAILURE; + goto finish; + } + Log(lc, LOG_TASK, "Starting server..."); if (!HttpServerStart(httpServer)) @@ -452,6 +467,7 @@ finish: Log(lc, LOG_DEBUG, "Freed HTTP Server."); } TelodendriaConfigFree(tConfig); + DbClose(matrixArgs.db); Log(lc, LOG_DEBUG, ""); MemoryIterate(TelodendriaMemoryIterator, lc); diff --git a/src/include/Matrix.h b/src/include/Matrix.h index f969696..0041b80 100644 --- a/src/include/Matrix.h +++ b/src/include/Matrix.h @@ -29,6 +29,7 @@ #include #include +#include /* * Abstract away the underlying data structure of the path so that @@ -90,6 +91,7 @@ typedef struct MatrixHttpHandlerArgs { LogConfig *lc; TelodendriaConfig *config; + Db *db; } MatrixHttpHandlerArgs; extern void