aboutsummaryrefslogtreecommitdiffstats
path: root/src/gammad.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-07-11 22:45:43 +0200
committerMattias Andrée <maandree@kth.se>2016-07-11 22:45:43 +0200
commit8b9426f86952224558b5534f4d906bb2c3a7ce6f (patch)
treec5e3029e1652ad17bd43cd0cfb7e70fc269006a1 /src/gammad.c
parentwhitespace + Add message.[ch] (diff)
downloadcoopgammad-8b9426f86952224558b5534f4d906bb2c3a7ce6f.tar.gz
coopgammad-8b9426f86952224558b5534f4d906bb2c3a7ce6f.tar.bz2
coopgammad-8b9426f86952224558b5534f4d906bb2c3a7ce6f.tar.xz
Add server.[ch]
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/gammad.c')
-rw-r--r--src/gammad.c9
1 files changed, 9 insertions, 0 deletions
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);