]> code.citadel.org Git - citadel.git/blobdiff - webcit/webserver.c
* start moving the hdr struct up, and add detach callback. Unfinished.
[citadel.git] / webcit / webserver.c
index 8488020effca4a1cae9f12ea8aed938d4de86b5a..f72910f114db0e835f9f79a76bb1301ab064f31f 100644 (file)
@@ -28,7 +28,7 @@ int follow_xff = 0;           /* Follow X-Forwarded-For: header */
 int home_specified = 0;                /* did the user specify a homedir? */
 int time_to_die = 0;            /* Nonzero if server is shutting down */
 int DisableGzip = 0;
-extern void *context_loop(int*);
+extern void *context_loop(ParsedHttpHdrs *Hdr);
 extern void *housekeeping_loop(void);
 extern pthread_mutex_t SessionListMutex;
 extern pthread_key_t MyConKey;
@@ -262,6 +262,7 @@ extern int LoadTemplates;
 extern HashList *HandlerHash;
 
 
+
 void
 webcit_calc_dirs_n_files(int relh, const char *basedir, int home, char *webcitdir, char *relhome)
 {
@@ -286,6 +287,9 @@ webcit_calc_dirs_n_files(int relh, const char *basedir, int home, char *webcitdi
        COMPUTE_DIRECTORY(static_icon_dir);
        basedir=WWWDIR "/static.local";
        COMPUTE_DIRECTORY(static_local_dir);
+       StripSlashes(static_dir, 1);
+       StripSlashes(static_icon_dir, 1);
+       StripSlashes(static_local_dir, 1);
 
        snprintf(file_crpt_file_key,
                 sizeof file_crpt_file_key, 
@@ -311,6 +315,7 @@ webcit_calc_dirs_n_files(int relh, const char *basedir, int home, char *webcitdi
  */
 int main(int argc, char **argv)
 {
+       size_t basesize = 2;            /* how big should strbufs be on creation? */
        pthread_t SessThread;           /* Thread descriptor */
        pthread_attr_t attr;            /* Thread attributes */
        int a, i;                       /* General-purpose variables */
@@ -352,9 +357,9 @@ int main(int argc, char **argv)
 
        /* Parse command line */
 #ifdef HAVE_OPENSSL
-       while ((a = getopt(argc, argv, "h:i:p:t:T:x:dD:G:cfsZ")) != EOF)
+       while ((a = getopt(argc, argv, "h:i:p:t:T:B:x:dD:G:cfsZ")) != EOF)
 #else
-       while ((a = getopt(argc, argv, "h:i:p:t:T:x:dD:G:cfZ")) != EOF)
+       while ((a = getopt(argc, argv, "h:i:p:t:T:B:x:dD:G:cfZ")) != EOF)
 #endif
                switch (a) {
                case 'h':
@@ -376,6 +381,11 @@ int main(int argc, char **argv)
                        pidfile = strdup(optarg);
                        running_as_daemon = 1;
                        break;
+               case 'B': /* Basesize */
+                       basesize = atoi(optarg);
+                       if (basesize > 2)
+                               StartLibCitadel(basesize);
+                       break;
                case 'i':
                        safestrncpy(ip_addr, optarg, sizeof ip_addr);
                        break;
@@ -480,15 +490,6 @@ int main(int argc, char **argv)
        lprintf(9, "Text domain Charset: %s\n", bind_textdomain_codeset("webcit","UTF8"));
 #endif
 
-
-
-
-
-
-
-
-
-
        initialise_modules();
        initialize_viewdefs();
        initialize_axdefs();
@@ -622,6 +623,10 @@ void worker_entry(void)
        int ret;
        struct timeval tv;
        fd_set readset, tempset;
+       ParsedHttpHdrs Hdr;
+
+       memset(&Hdr, 0, sizeof(ParsedHttpHdrs));
+       Hdr.HR.eReqType = eGET;
 
        tv.tv_sec = 0;
        tv.tv_usec = 10000;
@@ -721,9 +726,10 @@ void worker_entry(void)
 #endif
 
                        if (fail_this_transaction == 0) {
+                               Hdr.http_sock = ssock;
 
                                /* Perform an HTTP transaction... */
-                               context_loop(&ssock);
+                               context_loop(&Hdr);
 
                                /* Shut down SSL/TLS if required... */
 #ifdef HAVE_OPENSSL
@@ -733,14 +739,17 @@ void worker_entry(void)
 #endif
 
                                /* ...and close the socket. */
-                               if (ssock > 0)
+                               if (Hdr.http_sock > 0)
                                        lingering_close(ssock);
+                               http_detach_modules(&Hdr);
+
                        }
 
                }
 
        } while (!time_to_die);
 
+       http_destroy_modules(&Hdr);
        lprintf (1, "bye\n");
        pthread_exit(NULL);
 }