projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
77d93a3
)
Allow reuse of WebCit sessions currently resident in memory by unbinding unless the...
author
Art Cancro
<ajc@uncensored.citadel.org>
Mon, 11 Jul 2011 18:46:40 +0000
(14:46 -0400)
committer
Wilfried Goesgens
<dothebart@citadel.org>
Sun, 4 Sep 2011 21:34:29 +0000
(21:34 +0000)
webcit/context_loop.c
patch
|
blob
|
history
diff --git
a/webcit/context_loop.c
b/webcit/context_loop.c
index 225233ff2e7244b946644e46de925719daab540a..f9238ab6aee14d3e97669d76932371eacdc9bc42 100644
(file)
--- a/
webcit/context_loop.c
+++ b/
webcit/context_loop.c
@@
-188,6
+188,14
@@
wcsession *FindSession(wcsession **wclist, ParsedHttpHdrs *Hdr, pthread_mutex_t
}
break;
case NO_AUTH:
}
break;
case NO_AUTH:
+ /* Any unbound session is a candidate */
+ if (sptr->wc_session == 0) {
+ /* FIXME -- look for a session that is not only a candidate, but is
+ * also NOT CURRENTLY LOCKED. This will cause the proper size pool
+ * to be created.
+ */
+ TheSession = sptr;
+ }
break;
}
}
break;
}
}
@@
-477,6
+485,7
@@
void context_loop(ParsedHttpHdrs *Hdr)
wcsession *TheSession;
struct timeval tx_start;
struct timeval tx_finish;
wcsession *TheSession;
struct timeval tx_start;
struct timeval tx_finish;
+ int session_may_be_reused = 1;
gettimeofday(&tx_start, NULL); /* start a stopwatch for performance timing */
gettimeofday(&tx_start, NULL); /* start a stopwatch for performance timing */
@@
-535,6
+544,10
@@
void context_loop(ParsedHttpHdrs *Hdr)
CheckAuthBasic(Hdr);
}
CheckAuthBasic(Hdr);
}
+ if (Hdr->HR.got_auth) {
+ session_may_be_reused = 0;
+ }
+
/*
* See if there's an existing session open with the desired ID or user/pass
*/
/*
* See if there's an existing session open with the desired ID or user/pass
*/
@@
-593,6
+606,16
@@
void context_loop(ParsedHttpHdrs *Hdr)
session_detach_modules(TheSession);
session_detach_modules(TheSession);
+ /* If *this* very transaction did not explicitly specify a session cookie,
+ * and it did not log in, we want to flag the session as a candidate for
+ * re-use by the next unbound client that comes along. This keeps our session
+ * table from getting bombarded with new sessions when, for example, a web
+ * spider crawls the site without using cookies.
+ */
+ if ((session_may_be_reused) && (!WC->logged_in)) {
+ WC->wc_session = 0;
+ }
+
TheSession->Hdr = NULL;
CtdlLogResult(pthread_mutex_unlock(&TheSession->SessionMutex));
}
TheSession->Hdr = NULL;
CtdlLogResult(pthread_mutex_unlock(&TheSession->SessionMutex));
}