]> code.citadel.org Git - citadel.git/blobdiff - citadel/context.c
Correct logging expressions
[citadel.git] / citadel / context.c
index dce6841c0aa450aaa15d0cf3249073b29e2ee8c6..f54e3e57d2bab649d8ac905dc6fc46ea01a68e3f 100644 (file)
@@ -301,7 +301,7 @@ void terminate_idle_sessions(void)
        }
        end_critical_section(S_SESSION_TABLE);
        if (killed > 0)
-               CtdlLogPrintf(CTDL_INFO, "Terminated %d idle sessions\n", killed);
+               CtdlLogPrintf(CTDL_INFO, "Scheduled %d idle sessions for termination\n", killed);
        if (longrunners > 0)
                CtdlLogPrintf(CTDL_INFO, "Didn't terminate %d protected idle sessions;\n", killed);
 }
@@ -350,9 +350,15 @@ void RemoveContext (CitContext *con)
 
        CtdlLogPrintf(CTDL_NOTICE, "[%3d] Session ended.\n", con->cs_pid);
 
-       /* If the client is still connected, blow 'em away. */
-       CtdlLogPrintf(CTDL_DEBUG, "Closing socket %d\n", con->client_socket);
-       close(con->client_socket);
+       /* 
+        * If the client is still connected, blow 'em away. 
+        * if the socket is 0, its already gone or was never there.
+        */
+       if (con->client_socket != 0)
+       {
+               CtdlLogPrintf(CTDL_DEBUG, "Closing socket %d\n", con->client_socket);
+               close(con->client_socket);
+       }
 
        /* If using AUTHMODE_LDAP, free the DN */
        if (con->ldap_dn) {
@@ -448,9 +454,13 @@ CitContext *CloneContext(CitContext *CloneMe) {
        me->ldap_dn = NULL;
        me->session_specific_data = NULL;
 
+       me->download_fp = NULL;
+       me->upload_fp = NULL;
+       me->client_socket = 0;
+
        me->MigrateBuf = NewStrBuf();
        me->RecvBuf.Buf = NewStrBuf();
-
+       
        begin_critical_section(S_SESSION_TABLE);
        {
                me->cs_pid = ++next_pid;
@@ -513,6 +523,8 @@ void CtdlFillSystemContext(CitContext *context, char *name)
        len = cutuserkey(sysname);
        memcpy(context->curr_user, sysname, len + 1);
        context->client_socket = (-1);
+       context->state = CON_SYS;
+       context->ServiceName = name;
 
        /* internal_create_user has the side effect of loading the user regardless of wether they
         * already existed or needed to be created
@@ -567,7 +579,7 @@ void context_cleanup(void)
                rem = ptr->next;
                --num_sessions;
                
-               CtdlLogPrintf(CTDL_DEBUG, "Purging session %d\n", ptr->cs_pid);
+               CtdlLogPrintf(CTDL_DEBUG, "Purging session #%d %s\n", ptr->cs_pid, ptr->ServiceName);
                RemoveContext(ptr);
                free (ptr);
                ptr = rem;