*
* Copyright (c) 1996-2010 by the citadel.org team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
+ * This program is open source software. You can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "webcit.h"
* Lock the session list, moving any candidates for euthanasia into
* a separate list.
*/
- pthread_mutex_lock(&SessionListMutex);
+ CtdlLogResult(pthread_mutex_lock(&SessionListMutex));
for (sptr = SessionList; sptr != NULL; sptr = sptr->next) {
/* Kill idle sessions */
sessions_to_kill = sptr;
}
}
- pthread_mutex_unlock(&SessionListMutex);
+ CtdlLogResult(pthread_mutex_unlock(&SessionListMutex));
/*
* Now free up and destroy the culled sessions.
if (time_to_die) return; /* don't expand the thread pool during shutdown */
begin_critical_section(S_SPAWNER); /* only one of these should run at a time */
- while (
+ if (
(num_threads_executing >= num_threads_existing)
&& (num_threads_existing < MAX_WORKER_THREADS)
) {
GetAuthBasic(Hdr);
}
- pthread_mutex_lock(ListMutex);
+ CtdlLogResult(pthread_mutex_lock(ListMutex));
for (sptr = *wclist; ((sptr != NULL) && (TheSession == NULL)); sptr = sptr->next) {
/* If HTTP-AUTH, look for a session with matching credentials */
break;
}
}
- pthread_mutex_unlock(ListMutex);
+ CtdlLogResult(pthread_mutex_unlock(ListMutex));
if (TheSession == NULL)
lprintf(1, "didn't find sessionkey [%ld] for user [%s]\n",
Hdr->HR.SessionKey,ChrPtr(Hdr->c_username));
pthread_mutex_init(&TheSession->SessionMutex, NULL);
if (ListMutex != NULL)
- pthread_mutex_lock(ListMutex);
+ CtdlLogResult(pthread_mutex_lock(ListMutex));
if (wclist != NULL) {
TheSession->nonce = rand();
*wclist = TheSession;
}
if (ListMutex != NULL)
- pthread_mutex_unlock(ListMutex);
+ CtdlLogResult(pthread_mutex_unlock(ListMutex));
}
return TheSession;
}
OverrideRequest(Hdr, HKEY("GET /401 HTTP/1.0"));
Hdr->HR.prohibit_caching = 1;
}
+
+ /*
+ * I don't think we need this anymore now that guest mode is working
+ * ajc 2011jan07
+ *
else {
OverrideRequest(Hdr, HKEY("GET /static/nocookies.html?force_close_session=yes HTTP/1.0"));
Hdr->HR.prohibit_caching = 1;
}
+ */
}
if (StrLength(Hdr->c_language) > 0) {
/*
* Bind to the session and perform the transaction
*/
- pthread_mutex_lock(&TheSession->SessionMutex); /* bind */
+ CtdlLogResult(pthread_mutex_lock(&TheSession->SessionMutex));
pthread_setspecific(MyConKey, (void *)TheSession);
TheSession->lastreq = time(NULL); /* log */
session_detach_modules(TheSession);
TheSession->Hdr = NULL;
- pthread_mutex_unlock(&TheSession->SessionMutex); /* unbind */
+ CtdlLogResult(pthread_mutex_unlock(&TheSession->SessionMutex));
}
void tmplput_nonce(StrBuf *Target, WCTemplputParams *TP)
void Header_HandleHost(StrBuf *Line, ParsedHttpHdrs *hdr)
{
- if ((follow_xff) && (hdr->HR.http_host != NULL))
- return;
- else
- hdr->HR.http_host = Line;
+ if (site_prefix == NULL) {
+ site_prefix = NewStrBuf();
+ StrBufAppendPrintf(site_prefix, "%s://", (is_https ? "https" : "http") );
+ StrBufAppendBuf(site_prefix, Line, 0);
+ }
}
void Header_HandleXFFHost(StrBuf *Line, ParsedHttpHdrs *hdr)
{
- if (follow_xff)
- hdr->HR.http_host = Line;
+ if ( (follow_xff) && (site_prefix == NULL)) {
+ site_prefix = NewStrBuf();
+ StrBufAppendPrintf(site_prefix, "http://"); /* this is naive; do something about it */
+ StrBufAppendBuf(site_prefix, Line, 0);
+ }
}