* correct all GetNextHashPos() calls to have const chars
[citadel.git] / webcit / webserver.c
index 99cdfc2569344c7523fa0e3fa9423e9d83cff818..32887f47c642a0a0bd0421431bb751bde7aa1c07 100644 (file)
@@ -242,7 +242,8 @@ int client_read_to(int sock, char *buf, int bytes, int timeout)
  */
 void begin_burst(void)
 {
-       WC->WBuf = NewStrBufPlain(NULL, 32768);
+       if (WC->WBuf == NULL)
+               WC->WBuf = NewStrBufPlain(NULL, 32768);
 }
 
 
@@ -581,8 +582,13 @@ void spawn_another_worker_thread()
        pthread_attr_destroy(&attr);
 }
 
+//#define DBG_PRINNT_HOOKS_AT_START
+#ifdef DBG_PRINNT_HOOKS_AT_START
 const char foobuf[32];
 const char *nix(void *vptr) {snprintf(foobuf, 32, "%0x", (long) vptr); return foobuf;}
+#endif 
+void InitTemplateCache(void);
+
 /*
  * \brief Here's where it all begins.
  * \param argc number of commandline args
@@ -611,8 +617,18 @@ int main(int argc, char **argv)
        char uds_listen_path[PATH_MAX]; /*< listen on a unix domain socket? */
 
        HandlerHash = NewHash(1, NULL);
-       initialise_modules();
+       PreferenceHooks = NewHash(1, NULL);
+       WirelessTemplateCache = NewHash(1, NULL);
+       WirelessLocalTemplateCache = NewHash(1, NULL);
+       LocalTemplateCache = NewHash(1, NULL);
+       TemplateCache = NewHash(1, NULL);
+       GlobalNS = NewHash(1, NULL);
+       Iterators = NewHash(1, NULL);
+
+
+#ifdef DBG_PRINNT_HOOKS_AT_START
        dbg_PrintHash(HandlerHash, nix, NULL);
+#endif
 
        /* Ensure that we are linked to the correct version of libcitadel */
        if (libcitadel_version_number() < LIBCITADEL_VERSION_NUMBER) {
@@ -780,6 +796,9 @@ int main(int argc, char **argv)
                perror("chdir");
        }
        LoadIconDir(static_icon_dir);
+       InitTemplateCache();
+
+       initialise_modules();
        initialize_viewdefs();
        initialize_axdefs();
 
@@ -851,6 +870,8 @@ int main(int argc, char **argv)
        /* now the original thread becomes another worker */
        worker_entry();
        ShutDownLibCitadel ();
+       DeleteHash(&HandlerHash);
+       DeleteHash(&PreferenceHooks);
        return 0;
 }
 
@@ -926,6 +947,17 @@ void worker_entry(void)
                                icaltimezone_release_zone_tab ();
                                icalmemory_free_ring ();
                                ShutDownLibCitadel ();
+                               DeleteHash(&HandlerHash);
+                               DeleteHash(&PreferenceHooks);
+                               DeleteHash(&GlobalNS);
+                               DeleteHash(&WirelessTemplateCache);
+                               DeleteHash(&WirelessLocalTemplateCache);
+                               DeleteHash(&TemplateCache);
+                               DeleteHash(&LocalTemplateCache);
+                               DeleteHash(&Iterators);
+#ifdef ENABLE_NLS
+                               void ShutdownLocale(void);
+#endif
                                lprintf(2, "master shutdown exiting!.\n");                              
                                exit(0);
                        }