]> 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 ec920745fb6fd2f70c0f5d3fb174e07b78422342..dffd6eeb8ac7f378c244008b3a9352cbfa680b24 100644 (file)
@@ -45,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;
@@ -63,6 +76,9 @@ void do_housekeeping(void)
                        /* Remove sessions flagged for kill */
                        if (sptr->killthis) {
 
+                               lprintf(3, "Destroying session %d\n",
+                                       sptr->wc_session);
+
                                /* remove session from linked list */
                                if (sptr == SessionList) {
                                        SessionList = SessionList->next;
@@ -85,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);
                }
@@ -99,7 +116,7 @@ BREAKOUT:    pthread_mutex_unlock(&SessionListMutex);
 void housekeeping_loop(void)
 {
        while (1) {
-               sleep(HOUSEKEEPING);
+               sleeeeeeeeeep(HOUSEKEEPING);
                do_housekeeping();
        }
 }
@@ -109,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)
@@ -150,6 +167,7 @@ int req_gets(int sock, char *buf, char *hold)
                                return(0);
                        }
        }
+
        return(0);
 }
 
@@ -236,6 +254,7 @@ void context_loop(int sock)
        memset(hold, 0, sizeof(hold));
        do {
                if (req_gets(sock, buf, hold) < 0) return;
+
                if (!strncasecmp(buf, "Cookie: webcit=", 15)) {
                        cookie_to_stuff(&buf[15], &desired_session,
                                NULL, NULL, NULL);
@@ -268,6 +287,7 @@ void context_loop(int sock)
         */
        if (!strncasecmp(buf, "GET ", 4)) strcpy(buf, &buf[4]);
        else if (!strncasecmp(buf, "HEAD ", 5)) strcpy(buf, &buf[5]);
+       else if (!strncasecmp(buf, "POST ", 5)) strcpy(buf, &buf[5]);
        if (buf[1]==' ') buf[1]=0;
 
        /*