From 8b9426f86952224558b5534f4d906bb2c3a7ce6f Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 11 Jul 2016 22:45:43 +0200 Subject: Add server.[ch] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/gammad.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/gammad.c') diff --git a/src/gammad.c b/src/gammad.c index 7e981ad..6f83021 100644 --- a/src/gammad.c +++ b/src/gammad.c @@ -33,6 +33,7 @@ #include "arg.h" #include "output.h" #include "util.h" +#include "server.h" @@ -452,6 +453,7 @@ int main(int argc, char** argv) char* pidpath = NULL; char* socketpath = NULL; sigset_t mask; + int init_stage = 0; memset(&site, 0, sizeof(site)); @@ -686,6 +688,11 @@ int main(int argc, char** argv) if (signal(SIGTERM, sig_terminate) == SIG_ERR) goto fail; + /* Initialise the server */ + if (server_initialise() < 0) + goto fail; + init_stage++; + /* Place in the background unless -f */ if (foreground == 0) { @@ -781,6 +788,8 @@ int main(int argc, char** argv) /* Done */ rc = 0; done: + if (init_stage >= 1) + server_destroy(1); if (socketfd >= 0) { shutdown(socketfd, SHUT_RDWR); -- cgit v1.2.3-70-g09d2