/*
- * $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.
*
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;
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
*/
}
}
+/*
+ * 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) {
-/*
- pid_t tid = syscall(SYS_gettid);
-*/
- citthread_setspecific(MyConKey, (void *)which_con );
-/*
- CtdlLogPrintf(CTDL_DEBUG, "[%d]: Now doing %s\n",
- (int) tid,
- ((which_con != NULL) && (which_con->ServiceName != NULL)) ?
- which_con->ServiceName:"");
-*/
-}
-
/*
* Set the "async waiting" flag for a session, if applicable