#include <stdarg.h>
#include <pthread.h>
#include <signal.h>
-
-#ifdef WITH_ZLIB
-#include <zlib.h>
-#endif
-
#include "webcit.h"
#include "webserver.h"
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;
/* 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) {
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);
}
void housekeeping_loop(void)
{
while (1) {
- sleep(HOUSEKEEPING);
+ sleeeeeeeeeep(HOUSEKEEPING);
do_housekeeping();
}
}
* 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)
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
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)
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 */