]> code.citadel.org Git - citadel.git/blobdiff - webcit/context_loop.c
* Added the ability to compose messages with file attachments uploaded from
[citadel.git] / webcit / context_loop.c
index 9b744f13f12708675abade12df20fa94ff8f489d..dffd6eeb8ac7f378c244008b3a9352cbfa680b24 100644 (file)
 #include <stdarg.h>
 #include <pthread.h>
 #include <signal.h>
-
-#ifdef WITH_ZLIB
-#include <zlib.h>
-#endif
-
 #include "webcit.h"
 #include "webserver.h"
 
@@ -50,6 +45,19 @@ struct wcsession *SessionList = NULL;
 
 pthread_key_t MyConKey;                         /* TSD key for MySession() */
 
+
+void free_attachments(struct wcsession *sess) {
+       struct wc_attachment *att;
+
+       while (sess->first_attachment != NULL) {
+               att = sess->first_attachment;
+               sess->first_attachment = sess->first_attachment->next;
+               free(att->data);
+               free(att);
+       }
+}
+
+
 void do_housekeeping(void)
 {
        struct wcsession *sptr, *ss, *session_to_kill;
@@ -68,7 +76,8 @@ void do_housekeeping(void)
                        /* Remove sessions flagged for kill */
                        if (sptr->killthis) {
 
-                               lprintf(3, "Destroying session\n");
+                               lprintf(3, "Destroying session %d\n",
+                                       sptr->wc_session);
 
                                /* remove session from linked list */
                                if (sptr == SessionList) {
@@ -92,6 +101,7 @@ BREAKOUT:    pthread_mutex_unlock(&SessionListMutex);
                        if (session_to_kill->preferences != NULL) {
                                free(session_to_kill->preferences);
                        }
+                       free_attachments(session_to_kill);
                        pthread_mutex_unlock(&session_to_kill->SessionMutex);
                        free(session_to_kill);
                }
@@ -106,7 +116,7 @@ BREAKOUT:   pthread_mutex_unlock(&SessionListMutex);
 void housekeeping_loop(void)
 {
        while (1) {
-               sleep(HOUSEKEEPING);
+               sleeeeeeeeeep(HOUSEKEEPING);
                do_housekeeping();
        }
 }
@@ -116,7 +126,7 @@ void housekeeping_loop(void)
  * Generate a unique WebCit session ID (which is not the same thing as the
  * Citadel session ID).
  *
- * FIX ... ensure that session number is truly unique
+ * FIXME ... ensure that session number is truly unique
  *
  */
 int GenerateSessionID(void)
@@ -237,10 +247,6 @@ void context_loop(int sock)
        int desired_session = 0;
        int got_cookie = 0;
        struct wcsession *TheSession, *sptr;
-       char enc[SIZ];
-       char encodings[SIZ];
-       int gzip = 0;
-       int i;
 
        /*
         * Find out what it is that the web browser is asking for
@@ -255,16 +261,6 @@ void context_loop(int sock)
                        got_cookie = 1;
                }
 
-               if (!strncasecmp(buf, "Accept-encoding: ", 17)) {
-                       extract_token(encodings, &buf[17], 0, ';');
-                       for (i=0; i<num_tokens(encodings, ','); ++i) {
-                               extract_token(enc, encodings, i, ',');
-                               if (!strcasecmp(enc, "gzip")) {
-                                       gzip = 1;
-                               }
-                       }
-               }
-
                hptr = (struct httprequest *)
                        malloc(sizeof(struct httprequest));
                if (req == NULL)
@@ -355,7 +351,7 @@ void context_loop(int sock)
        pthread_setspecific(MyConKey, (void *)TheSession);
        TheSession->http_sock = sock;
        TheSession->lastreq = time(NULL);                       /* log */
-       session_loop(req, gzip);        /* perform the requested transaction */
+       session_loop(req);              /* perform the requested transaction */
        pthread_mutex_unlock(&TheSession->SessionMutex);        /* unbind */
 
        /* Free the request buffer */