* cleanup shutdown procedure; free all structures and their properties
[citadel.git] / webcit / webserver.c
index 315f26727c641e8c2cd7a317e903056bb1c7617f..36c64a5f4155863c1dc82c815361cb49216de463 100644 (file)
@@ -275,7 +275,8 @@ long end_burst(void)
 
 #ifdef HAVE_OPENSSL
        if (is_https) {
-               client_write_ssl(ptr, StrLength(WCC->HBuf));
+               client_write_ssl(WCC->HBuf);
+               client_write_ssl(WCC->WBuf);
                return (count);
        }
 #endif
@@ -289,7 +290,7 @@ long end_burst(void)
 #endif
        fdflags = fcntl(WC->http_sock, F_GETFL);
 
-        while (ptr < eptr) {
+       while (ptr < eptr) {
                 if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
                         FD_ZERO(&wset);
                         FD_SET(WCC->http_sock, &wset);
@@ -313,13 +314,6 @@ long end_burst(void)
        count = StrLength(WCC->WBuf);
        eptr = ptr + count;
 
-#ifdef HAVE_OPENSSL
-       if (is_https) {
-               client_write_ssl(ptr, StrLength(WCC->HBuf));
-               return (count);
-       }
-#endif
-
 #ifdef HTTP_TRACING
        
        write(2, "\033[34m", 5);
@@ -587,7 +581,9 @@ void spawn_another_worker_thread()
 const char foobuf[32];
 const char *nix(void *vptr) {snprintf(foobuf, 32, "%0x", (long) vptr); return foobuf;}
 #endif 
+void InitTemplateCache(void);
 
+extern void LoadZoneFiles(void);
 /*
  * \brief Here's where it all begins.
  * \param argc number of commandline args
@@ -617,8 +613,15 @@ int main(int argc, char **argv)
 
        HandlerHash = NewHash(1, NULL);
        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);
+       Contitionals = NewHash(1, NULL);
+       LoadZoneFiles();
 
-       initialise_modules();
 
 #ifdef DBG_PRINNT_HOOKS_AT_START
        dbg_PrintHash(HandlerHash, nix, NULL);
@@ -790,6 +793,9 @@ int main(int argc, char **argv)
                perror("chdir");
        }
        LoadIconDir(static_icon_dir);
+       InitTemplateCache();
+
+       initialise_modules();
        initialize_viewdefs();
        initialize_axdefs();
 
@@ -867,6 +873,27 @@ int main(int argc, char **argv)
 }
 
 
+void ShutDownWebcit(void)
+{
+       DeleteHash(&ZoneHash);
+       free_zone_directory ();
+       icaltimezone_release_zone_tab ();
+       icalmemory_free_ring ();
+       ShutDownLibCitadel ();
+       DeleteHash(&HandlerHash);
+       DeleteHash(&PreferenceHooks);
+       DeleteHash(&GlobalNS);
+       DeleteHash(&WirelessTemplateCache);
+       DeleteHash(&WirelessLocalTemplateCache);
+       DeleteHash(&TemplateCache);
+       DeleteHash(&LocalTemplateCache);
+       DeleteHash(&Iterators);
+       DeleteHash(&Contitionals);
+#ifdef ENABLE_NLS
+       ShutdownLocale();
+#endif
+}
+
 /*
  * Entry point for worker threads
  */
@@ -934,15 +961,9 @@ void worker_entry(void)
                                lprintf(2, "master shutdown: cleaning up sessions\n");
                                do_housekeeping();
                                lprintf(2, "master shutdown: cleaning up libical\n");
-                               free_zone_directory ();
-                               icaltimezone_release_zone_tab ();
-                               icalmemory_free_ring ();
-                               ShutDownLibCitadel ();
-                               DeleteHash(&HandlerHash);
-                               DeleteHash(&PreferenceHooks);
-#ifdef ENABLE_NLS
-                               void ShutdownLocale(void);
-#endif
+
+                               ShutDownWebcit();
+
                                lprintf(2, "master shutdown exiting!.\n");                              
                                exit(0);
                        }