Functions | |
void | free_attachments (struct wcsession *sess) |
free the memory used for viewing atachments | |
void | do_housekeeping (void) |
what?????? | |
void | housekeeping_loop (void) |
Wake up occasionally and clean house. | |
int | GenerateSessionID (void) |
Create a Session id Generate a unique WebCit session ID (which is not the same thing as the Citadel session ID). | |
int | req_gets (int sock, char *buf, char *hold) |
Collapse multiple cookies on one line. | |
int | lingering_close (int fd) |
close some fd for some reason??? | |
int | is_bogus (char *http_cmd) |
sanity requests Check for bogus requests coming from brain-dead Windows boxes. | |
void | context_loop (int sock) |
handle one request This loop gets called once for every HTTP connection made to WebCit. At this entry point we have an HTTP socket with a browser allegedly on the other end, but we have not yet bound to a WebCit session. | |
Variables | |
pthread_mutex_t | SessionListMutex |
wcsession * | SessionList = NULL |
pthread_key_t | MyConKey |
void free_attachments | ( | struct wcsession * | sess | ) |
free the memory used for viewing atachments
sess | the session object to destroy |
Definition at line 29 of file context_loop.c.
References wc_attachment::data, wcsession::first_attachment, and wc_attachment::next.
Referenced by post_message().
void do_housekeeping | ( | void | ) |
what??????
Lock the session list, moving any candidates for euthanasia into a separate list.
Kill idle sessions
Remove sessions flagged for kill
remove session from linked list
Now free up and destroy the culled sessions.
If there are more sessions than threads, then we should spawn more threads ... up to a predefined maximum.
Definition at line 43 of file context_loop.c.
References wcsession::killthis, wcsession::lastreq, wcsession::next, SessionList, and SessionListMutex.
Referenced by housekeeping_loop().
int GenerateSessionID | ( | void | ) |
Create a Session id Generate a unique WebCit session ID (which is not the same thing as the Citadel session ID).
Definition at line 141 of file context_loop.c.
int req_gets | ( | int | sock, | |
char * | buf, | |||
char * | hold | |||
) |
Collapse multiple cookies on one line.
sock | a socket? | |
buf | some bunch of chars? | |
hold | hold what? |
Definition at line 159 of file context_loop.c.
References client_getln(), and safestrncpy().
Referenced by context_loop().
int lingering_close | ( | int | fd | ) |
close some fd for some reason???
fd | the fd to close?????? lingering_close() a`la Apache. see http://www.apache.org/docs/misc/fin_wait_2.html for rationale |
Definition at line 193 of file context_loop.c.
Referenced by worker_entry().
int is_bogus | ( | char * | http_cmd | ) |
sanity requests Check for bogus requests coming from brain-dead Windows boxes.
http_cmd | The HTTP request to check |
< Worms and trojans and viruses, oh my!
< Broken Microsoft DAV implementation
< Stoopid MSOffice thinks everyone is IIS
Definition at line 233 of file context_loop.c.
References url().
Referenced by context_loop().
void context_loop | ( | int | sock | ) |
handle one request This loop gets called once for every HTTP connection made to WebCit. At this entry point we have an HTTP socket with a browser allegedly on the other end, but we have not yet bound to a WebCit session.
The job of this function is to locate the correct session and bind to it, or create a session if necessary and bind to it, then run the WebCit transaction loop. Afterwards, we unbind from the session. When this function returns, the worker thread is then free to handle another transaction.
sock | the socket we will put our answer to |
Find out what it is that the web browser is asking for
Can we compress?
Browser-based sessions use cookies for session authentication
GroupDAV-based sessions use HTTP authentication
Read in the request
If the request is prefixed by "/webcit" then chop that off. This allows a front end web server to forward all /webcit requests to us while still using the same web server port for other things.
Begin parsing the request.
Check for bogus requests
Strip out the method, leaving the URL up front...
While we're at it, gracefully handle requests for the robots.txt and favicon.ico files.
These are the URL's which may be executed without a session cookie already set. If it's not one of these, force the session to close because cookies are probably disabled on the client browser.
See if there's an existing session open with the desired ID or user/pass
If HTTP-AUTH, look for a session with matching credentials
If cookie-session, look for a session with matching session ID
Create a new session if we have to
A future improvement might be to check the session integrity at this point before continuing.
Bind to the session and perform the transaction
Free the request buffer
Free up any session-local substitution variables which were set during this transaction
Definition at line 275 of file context_loop.c.
References cookie_to_stuff(), CtdlDecodeBase64(), extract_token(), wcsession::httpauth_pass, wcsession::httpauth_user, httpdate_to_timestamp(), if_modified_since, is_bogus(), httprequest::line, lprintf(), httprequest::next, wcsession::next, remove_token(), req_gets(), safestrncpy(), SessionList, SessionListMutex, and wcsession::wc_session.
Referenced by worker_entry().
pthread_mutex_t SessionListMutex |
Only one thread may manipulate SessionList at a time...
Definition at line 18 of file context_loop.c.
Referenced by context_loop(), do_housekeeping(), and main().
struct wcsession* SessionList = NULL |
our sessions ????
Definition at line 20 of file context_loop.c.
Referenced by context_loop(), and do_housekeeping().
pthread_key_t MyConKey |