/*
- * $Id: sysdep.c 7989 2009-10-31 15:29:37Z davew $
- *
* Citadel context management stuff.
* Here's where we (hopefully) have all the code that manipulates contexts.
*
#include <sys/socket.h>
#include <syslog.h>
#include <sys/syslog.h>
+/*
+#include <sys/syscall.h>
+*/
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
if (session_num == ccptr->cs_pid) {
ret |= TERM_FOUND;
if ((ccptr->user.usernum == CC->user.usernum)
- || (CC->user.axlevel >= 6)) {
+ || (CC->user.axlevel >= AxAideU)) {
ret |= TERM_ALLOWED;
ccptr->kill_me = 1;
}
FreeStrBuf(&con->MigrateBuf);
FreeStrBuf(&con->ReadBuf);
+ FreeStrBuf(&con->lBuf);
CtdlLogPrintf(CTDL_DEBUG, "Done with RemoveContext()\n");
}
return NULL;
}
memset(me, 0, sizeof(CitContext));
-
+ me->lBuf = NewStrBufPlain(NULL, SIZ);
/* Give the contaxt a name. Hopefully makes it easier to track */
strcpy (me->user.fullname, "SYS_notauth");
me->cs_pid = ++next_pid;
me->prev = NULL;
me->next = ContextList;
+ me->lastcmd = time(NULL); /* set lastcmd to now to prevent idle timer infanticide */
ContextList = me;
if (me->next != NULL) {
me->next->prev = me;
*/
void CtdlFillSystemContext(CitContext *context, char *name)
{
- char sysname[USERNAME_SIZE];
+ char sysname[SIZ];
+ long len;
memset(context, 0, sizeof(CitContext));
+ context->lBuf = NewStrBuf();
context->internal_pgm = 1;
context->cs_pid = 0;
strcpy (sysname, "SYS_");
strcat (sysname, name);
+ len = cutuserkey(sysname);
+ memcpy(context->curr_user, sysname, len + 1);
+
/* internal_create_user has the side effect of loading the user regardless of wether they
* already existed or needed to be created
*/
- internal_create_user (sysname, &(context->user), -1) ;
+ internal_create_user (sysname, len, &(context->user), -1) ;
/* Check to see if the system user needs upgrading */
if (context->user.usernum == 0)
}
}
+/*
+ * flush it again...
+ */
+void CtdlClearSystemContext(void)
+{
+ CitContext *CCC = CC;
+
+ FreeStrBuf(&CCC->lBuf);
+ memset(CCC, 0, sizeof(CitContext));
+ citthread_setspecific(MyConKey, NULL);
+}
+
/*
* Cleanup any contexts that are left lying around
*/
memset(&masterCC, 0, sizeof( CitContext));
masterCC.internal_pgm = 1;
masterCC.cs_pid = 0;
+ masterCC.lBuf = NewStrBuf ();
}
-/*
- * Bind a thread to a context. (It's inline merely to speed things up.)
- */
-INLINE void become_session(CitContext *which_con) {
- citthread_setspecific(MyConKey, (void *)which_con );
-}
-
/*
* Set the "async waiting" flag for a session, if applicable
{
CtdlLogPrintf(CTDL_DEBUG, "Setting async_waiting flag for session %d\n", ccptr->cs_pid);
if (ccptr->is_async) {
- ccptr->async_waiting = 1;
+ ccptr->async_waiting++;
if (ccptr->state == CON_IDLE) {
ccptr->state = CON_READY;
}