* HAIL MELD!
[citadel.git] / webcit / context_loop.c
index 79687511cf3aa47a43a65e5d4f923aca0d46bd2a..e505b5465d00606e231372d2e7433c9ded6a035b 100644 (file)
@@ -34,6 +34,30 @@ void free_attachments(struct wcsession *sess) {
 }
 
 
+void DestroySession(struct wcsession **sessions_to_kill)
+{
+       close((*sessions_to_kill)->serv_sock);
+       close((*sessions_to_kill)->chat_sock);
+//             if ((*sessions_to_kill)->preferences != NULL) {
+//                     free((*sessions_to_kill)->preferences);
+//             }
+       if ((*sessions_to_kill)->cache_fold != NULL) {
+               free((*sessions_to_kill)->cache_fold);
+       }
+       free_attachments((*sessions_to_kill));
+       free_march_list((*sessions_to_kill));
+       DeleteHash(&((*sessions_to_kill)->hash_prefs));
+       DeleteHash(&((*sessions_to_kill)->IconBarSetttings));
+       DeleteHash(&((*sessions_to_kill)->ServCfg));
+       FreeStrBuf(&((*sessions_to_kill)->UrlFragment1));
+       FreeStrBuf(&((*sessions_to_kill)->UrlFragment2));
+       FreeStrBuf(&((*sessions_to_kill)->WBuf));
+       FreeStrBuf(&((*sessions_to_kill)->HBuf));
+
+       free((*sessions_to_kill));
+       (*sessions_to_kill) = NULL;
+}
+
 void shutdown_sessions(void)
 {
        struct wcsession *sptr;
@@ -90,22 +114,10 @@ void do_housekeeping(void)
        while (sessions_to_kill != NULL) {
                lprintf(3, "Destroying session %d\n", sessions_to_kill->wc_session);
                pthread_mutex_lock(&sessions_to_kill->SessionMutex);
-               close(sessions_to_kill->serv_sock);
-               close(sessions_to_kill->chat_sock);
-//             if (sessions_to_kill->preferences != NULL) {
-//                     free(sessions_to_kill->preferences);
-//             }
-               if (sessions_to_kill->cache_fold != NULL) {
-                       free(sessions_to_kill->cache_fold);
-               }
-               free_attachments(sessions_to_kill);
-               free_march_list(sessions_to_kill);
-               clear_substs(sessions_to_kill);
-               DeleteHash(&(sessions_to_kill->hash_prefs));
-               
                pthread_mutex_unlock(&sessions_to_kill->SessionMutex);
                sptr = sessions_to_kill->next;
-               free(sessions_to_kill);
+
+               DestroySession(&sessions_to_kill);
                sessions_to_kill = sptr;
                --num_sessions;
        }
@@ -159,7 +171,7 @@ int GenerateSessionID(void)
 /*
  * Collapse multiple cookies on one line
  */
-int req_gets(int sock, char *buf, char *hold, size_t hlen)
+int req_gets(int *sock, char *buf, char *hold, size_t hlen)
 {
        int a, b;
 
@@ -279,7 +291,7 @@ int is_bogus(char *http_cmd) {
  * transaction.
  * \param sock the socket we will put our answer to
  */
-void context_loop(int sock)
+void context_loop(int *sock)
 {
        struct httprequest *req = NULL;
        struct httprequest *last = NULL;
@@ -374,10 +386,17 @@ void context_loop(int sock)
                strcpy(ptr+1, ptr+8);
        }
 
-       /** Begin parsing the request. */
-
        safestrncpy(buf, req->line, sizeof buf);
-       lprintf(5, "HTTP: %s\n", buf);
+       /** Begin parsing the request. */
+#ifdef TECH_PREVIEW
+       if ((strncmp(req->line+4, "/sslg", 5) != 0) &&
+           (strncmp(req->line+4, "/static/", 8) != 0) &&
+           (strncmp(req->line+4, "/wholist_section", 16) != 0)) {
+#endif
+               lprintf(5, "HTTP: %s\n", buf);
+#ifdef TECH_PREVIEW
+       }
+#endif
 
        /** Check for bogus requests */
        if (is_bogus(buf)) {
@@ -473,10 +492,13 @@ void context_loop(int sock)
 
                strcpy(TheSession->httpauth_user, httpauth_user);
                strcpy(TheSession->httpauth_pass, httpauth_pass);
-               TheSession->hash_prefs = NewHash();     /* Get a hash table for the user preferences */
+               TheSession->hash_prefs = NewHash(1,NULL);       /* Get a hash table for the user preferences */
                pthread_mutex_init(&TheSession->SessionMutex, NULL);
                pthread_mutex_lock(&SessionListMutex);
+               TheSession->urlstrings = NULL;
+               TheSession->vars = NULL;
                TheSession->nonce = rand();
+               TheSession->WBuf = NULL;
                TheSession->next = SessionList;
                SessionList = TheSession;
                pthread_mutex_unlock(&SessionListMutex);
@@ -493,7 +515,10 @@ void context_loop(int sock)
         */
        pthread_mutex_lock(&TheSession->SessionMutex);          /* bind */
        pthread_setspecific(MyConKey, (void *)TheSession);
-       TheSession->http_sock = sock;
+       
+       TheSession->urlstrings = NewHash(1,NULL);
+       TheSession->vars = NewHash(1,NULL);
+       TheSession->http_sock = *sock;
        TheSession->lastreq = time(NULL);                       /* log */
        TheSession->gzip_ok = gzip_ok;
 #ifdef ENABLE_NLS
@@ -506,6 +531,12 @@ void context_loop(int sock)
 #ifdef ENABLE_NLS
        stop_selected_language();                               /* unset locale */
 #endif
+       DeleteHash(&TheSession->urlstrings);
+       DeleteHash(&TheSession->vars);
+       FreeStrBuf(&TheSession->WBuf);
+       FreeStrBuf(&TheSession->HBuf);
+       
+       
        pthread_mutex_unlock(&TheSession->SessionMutex);        /* unbind */
 
        /* Free the request buffer */
@@ -519,5 +550,6 @@ void context_loop(int sock)
         * Free up any session-local substitution variables which
         * were set during this transaction
         */
-       clear_local_substs();
+       
+       
 }