]> code.citadel.org Git - citadel.git/blobdiff - citadel/context.c
Use IOBuffer with its StrBuf + const char* inside instead of having two of them
[citadel.git] / citadel / context.c
index f6bbf58b635d95fdd1b6fd6b7aae348adfaebdcf..ad4332160d7f7d1e3230dfeb52e693ecb8e20fb8 100644 (file)
@@ -306,6 +306,25 @@ void terminate_idle_sessions(void)
                CtdlLogPrintf(CTDL_INFO, "Didn't terminate %d protected idle sessions;\n", killed);
 }
 
+void terminate_stuck_sessions(void)
+{
+       CitContext *ccptr;
+       int killed = 0;
+
+       begin_critical_section(S_SESSION_TABLE);
+       for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
+               if (ccptr->client_socket != -1)
+               {
+                       close(ccptr->client_socket);
+                       ccptr->client_socket = -1;
+                       killed++;
+               }
+       }
+       end_critical_section(S_SESSION_TABLE);
+       if (killed > 0)
+               CtdlLogPrintf(CTDL_INFO, "Flushed %d stuck sessions\n", killed);
+}
+
 
 
 /*
@@ -342,7 +361,7 @@ void RemoveContext (CitContext *con)
        }
 
        FreeStrBuf(&con->MigrateBuf);
-       FreeStrBuf(&con->ReadBuf);
+       FreeStrBuf(&con->RecvBuf.Buf);
        CtdlLogPrintf(CTDL_DEBUG, "Done with RemoveContext()\n");
 }
 
@@ -378,7 +397,7 @@ CitContext *CreateNewContext(void) {
         * the list.
         */
        me->MigrateBuf = NewStrBuf();
-       me->ReadBuf = NewStrBuf();
+       me->RecvBuf.Buf = NewStrBuf();
        begin_critical_section(S_SESSION_TABLE);
        me->cs_pid = ++next_pid;
        me->prev = NULL;
@@ -449,7 +468,7 @@ void CtdlFillSystemContext(CitContext *context, char *name)
        if (context->user.usernum == 0)
        {       /* old system user with number 0, upgrade it */
                context->user.usernum = get_new_user_number();
-               CtdlLogPrintf(CTDL_DEBUG, "Upgrading system user \"%s\" from user number 0 to user number %d\n", context->user.fullname, context->user.usernum);
+               CtdlLogPrintf(CTDL_DEBUG, "Upgrading system user \"%s\" from user number 0 to user number %ld\n", context->user.fullname, context->user.usernum);
                /* add user to the database */
                CtdlPutUser(&(context->user));
                cdb_store(CDB_USERSBYNUMBER, &(context->user.usernum), sizeof(long), context->user.fullname, strlen(context->user.fullname)+1);