* keep track of things. If the HTTP request doesn't belong to any currently
* active session, a new session is started.
*
- * Copyright (c) 1996-2011 by the citadel.org team
+ * Copyright (c) 1996-2012 by the citadel.org team
*
* This program is open source software. You can redistribute it and/or
* modify it under the terms of the GNU General Public License version 3.
{
wcsession *sptr, *ss;
wcsession *sessions_to_kill = NULL;
+ time_t the_time;
/*
* Lock the session list, moving any candidates for euthanasia into
*/
CtdlLogResult(pthread_mutex_lock(&SessionListMutex));
for (sptr = SessionList; sptr != NULL; sptr = sptr->next) {
-
+ if (the_time == 0)
+ the_time = time(NULL);
/* Kill idle sessions */
- if ((time(NULL) - (sptr->lastreq)) > (time_t) WEBCIT_TIMEOUT) {
+ if ((sptr->inuse == 0) &&
+ ((the_time - (sptr->lastreq)) > (time_t) WEBCIT_TIMEOUT))
+ {
syslog(3, "Timeout session %d", sptr->wc_session);
sptr->killthis = 1;
}
);
}
else {
- Hdr->HR.DontNeedAuth = 1; /* Flat request? show him the login screen... */
- StrBuf *NewLine = NewStrBufPlain(HKEY("GET /readfwd?go="));
- StrBufUrlescAppend(NewLine, Buf, NULL);
- StrBufAppendBufPlain(NewLine, HKEY(" HTTP/1.0"), 0);
+ /* If this is a "flat" request for the root, display the configured landing page. */
+ int return_value;
+ StrBuf *NewLine = NewStrBuf();
+ Hdr->HR.DontNeedAuth = 1;
+ StrBufAppendPrintf(NewLine, "GET /landing?go=%s HTTP/1.0", ChrPtr(Buf));
syslog(LOG_DEBUG, "Replacing with: %s", ChrPtr(NewLine));
- int return_value = ReadHttpSubject(Hdr, NewLine, Buf);
+ return_value = ReadHttpSubject(Hdr, NewLine, Buf);
FreeStrBuf(&NewLine);
return return_value;
}
/*
* If there were no qualifying sessions, then create a new one.
*/
- if (TheSession == NULL) {
+ if ((TheSession == NULL) || (TheSession->killthis != 0)) {
TheSession = CreateSession(1, 0, &SessionList, Hdr, &SessionListMutex);
}