session: moves initialisation to main
authorJosé Bollo <jose.bollo@iot.bzh>
Wed, 23 Mar 2016 15:45:19 +0000 (16:45 +0100)
committerJosé Bollo <jose.bollo@iot.bzh>
Wed, 23 Mar 2016 15:45:19 +0000 (16:45 +0100)
Change-Id: I038d5624dc2f32e2c2d54b7e6ea388cb61122ccd
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
src/http-svc.c
src/main.c
src/session.c

index 99c4142..480925d 100644 (file)
@@ -325,9 +325,6 @@ AFB_error httpdStart(AFB_session * session)
                return AFB_FATAL;
        }
 
-       /* Initialise Client Session Hash Table */
-       ctxStoreInit(CTX_NBCLIENTS);
-
 #if defined(USE_MAGIC_MIME_TYPE)
        /*TBD open libmagic cache [fail to pass EFENCE check (allocating 0 bytes)] */
        init_lib_magic (session);
index f73cfac..e9cddcb 100644 (file)
@@ -503,8 +503,6 @@ int main(int argc, char *argv[])  {
   on_exit(closeSession, session);
   parse_arguments(argc, argv, session);
 
-  initPlugins(session);
-
   // ------------------ sanity check ----------------------------------------
   if  ((session->background) && (session->foreground)) {
     fprintf (stderr, "ERR: cannot select foreground & background at the same time\n");
@@ -515,6 +513,9 @@ int main(int argc, char *argv[])  {
      exit (1);
   }
 
+  initPlugins(session);
+  ctxStoreInit(CTX_NBCLIENTS);
+
   // ------------------ Some useful default values -------------------------
   if  ((session->background == 0) && (session->foreground == 0)) session->foreground=1;
 
index 9d03d0a..3b9288f 100644 (file)
@@ -343,7 +343,7 @@ PUBLIC void ctxStoreInit (int nbSession) {
    
    // let's create as store as hashtable does not have any
    sessions.store = calloc (1 + (unsigned)nbSession, sizeof(AFB_clientCtx));
-   sessions.max=nbSession;
+   sessions.max = nbSession;
 }
 
 STATIC AFB_clientCtx *ctxStoreSearch (const char* uuid) {