* start moving the hdr struct up, and add detach callback. Unfinished.
authorWilfried Göesgens <willi@citadel.org>
Sun, 31 May 2009 19:46:52 +0000 (19:46 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 31 May 2009 19:46:52 +0000 (19:46 +0000)
webcit/auth.c
webcit/context_loop.c
webcit/mk_module_init.sh
webcit/webserver.c

index 22dbcfbf29911dba2adc680d3c004189487f6a80..57f9b39a64a530dda010534f6f45f193a09f8645 100644 (file)
@@ -981,6 +981,16 @@ void Header_HandleCookie(StrBuf *Line, ParsedHttpHdrs *hdr)
        hdr->HR.got_auth = AUTH_COOKIE;
 }
 
+void 
+HttpDetachModule_AUTH
+(ParsedHttpHdrs *httpreq)
+{
+       FLUSHStrBuf(httpreq->c_username);
+       FLUSHStrBuf(httpreq->c_password);
+       FLUSHStrBuf(httpreq->c_roomname);
+       FLUSHStrBuf(httpreq->c_language);
+}
+
 void 
 HttpDestroyModule_AUTH
 (ParsedHttpHdrs *httpreq)
index 8dcd5d687b4b5f592694fd619d1e081f3bc00af2..bce424d3033bb76749f0c69d4ebffdd8cbbe2056 100644 (file)
@@ -477,7 +477,6 @@ void context_loop(ParsedHttpHdrs *Hdr)
                        ChrPtr(Hdr->this_page)
                        );
                session_detach_modules(Bogus);
-               http_destroy_modules(Hdr);
                session_destroy_modules(&Bogus);
                return;
        }
@@ -504,7 +503,6 @@ void context_loop(ParsedHttpHdrs *Hdr)
                                ChrPtr(Hdr->this_page)
                                );
                session_detach_modules(Static);
-               http_destroy_modules(Hdr);
                session_destroy_modules(&Static);
                return;
        }
@@ -575,8 +573,6 @@ TODO    HKEY("/static/nocookies.html?force_close_session=yes"));
 
        TheSession->Hdr = NULL;
        pthread_mutex_unlock(&TheSession->SessionMutex);        /* unbind */
-
-       http_destroy_modules(Hdr);
 }
 
 void tmplput_nonce(StrBuf *Target, WCTemplputParams *TP)
@@ -768,6 +764,17 @@ InitModule_CONTEXT
        
 
 
+void 
+HttpDetachModule_CONTEXT
+(ParsedHttpHdrs *httpreq)
+{
+       FlushStrBuf(httpreq->ReadBuf);
+       FlushStrBuf(httpreq->PlainArgs);
+       FlushStrBuf(httpreq->this_page);
+       DeleteHash(&httpreq->HTTPHeaders);
+       memset(&httpreq->HR, 0, sizeof(HdrRefs));
+}
+
 void 
 HttpDestroyModule_CONTEXT
 (ParsedHttpHdrs *httpreq)
index 61fe9318afba03dae8685ea3e123562aa33ecb18..17bf2729896c48a11cbfc75312c0ee6ec8b5fd9a 100755 (executable)
@@ -43,6 +43,7 @@ SESS_ATTACH_FUNCS=`grep SessionAttachModule_ *.c |sed "s;.*:;;" |sort -u`
 SESS_DETACH_FUNCS=`grep SessionDetachModule_ *.c |sed "s;.*:;;" |sort -u`
 SESS_DESTROY_FUNCS=`grep SessionDestroyModule_ *.c |sed "s;.*:;;" |sort -u`
 
+HTTP_DETACH_FUNCS=`grep HttpDetachModule_ *.c |sed "s;.*:;;" |sort -u`
 HTTP_DESTROY_FUNCS=`grep HttpDestroyModule_ *.c |sed "s;.*:;;" |sort -u`
 
 
@@ -78,6 +79,7 @@ void session_attach_modules (wcsession *sess);
 void session_detach_modules (wcsession *sess);
 void session_destroy_modules (wcsession **sess);
 
+void http_detach_modules (ParsedHttpHdrs *httpreq);
 void http_destroy_modules (ParsedHttpHdrs *httpreq);
 
 
@@ -369,6 +371,35 @@ EOF
 
 
 
+#********************************************************************************
+# DETACH-Httprequest module logic.
+#********************************************************************************
+cat <<EOF >> $C_FILE
+
+void http_detach_modules (ParsedHttpHdrs *httpreq)
+{
+EOF
+
+for HOOK in $HTTP_DETACH_FUNCS; do
+HOOKNAME=`echo $HOOK |sed "s;HttpDetachModule_;;"`
+# Add this entry point to the .c file
+cat <<EOF >> $C_FILE
+#ifdef DBG_PRINNT_HOOKS_AT_START
+       lprintf (CTDL_INFO, "Detaching $HOOKNAME\n");
+#endif
+       $HOOK(httpreq);
+EOF
+# Add this entry point to the .h file
+cat <<EOF >> $H_FILE
+extern void $HOOK(ParsedHttpHdrs *httpreq);
+EOF
+done
+
+cat <<EOF  >>$C_FILE
+}
+EOF
+
+
 #********************************************************************************
 # DESTROY-Httprequest module logic.
 #********************************************************************************
index 4479c0a5a428ee90257f0f90a7cf7f99e2ba6c92..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;
@@ -623,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;
@@ -722,9 +726,6 @@ void worker_entry(void)
 #endif
 
                        if (fail_this_transaction == 0) {
-                               ParsedHttpHdrs Hdr;
-                               memset(&Hdr, 0, sizeof(ParsedHttpHdrs));
-                               Hdr.HR.eReqType = eGET;
                                Hdr.http_sock = ssock;
 
                                /* Perform an HTTP transaction... */
@@ -740,12 +741,15 @@ void worker_entry(void)
                                /* ...and close the socket. */
                                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);
 }