Fix warnings all over citserver; handle function replies; remove unused code.
[citadel.git] / citadel / context.c
index c77f3cdd2b007eb4fa8c5425ef3b0c63a1d3d16e..0b433502e4fd4c9e234c4012eb643df2ea829d7f 100644 (file)
@@ -276,30 +276,31 @@ void terminate_idle_sessions(void)
 {
        CitContext *ccptr;
        time_t now;
-       int session_to_kill;
        int killed = 0;
        int longrunners = 0;
 
        now = time(NULL);
-       session_to_kill = 0;
        begin_critical_section(S_SESSION_TABLE);
        for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
-               if (  (ccptr!=CC)
-               && (config.c_sleeping > 0)
-               && (now - (ccptr->lastcmd) > config.c_sleeping) ) {
+               if (
+                       (ccptr != CC)
+                       && (config.c_sleeping > 0)
+                       && (now - (ccptr->lastcmd) > config.c_sleeping)
+               ) {
                        if (!ccptr->dont_term) {
                                ccptr->kill_me = KILLME_IDLE;
                                ++killed;
                        }
-                       else 
-                               longrunners ++;
+                       else {
+                               ++longrunners;
+                       }
                }
        }
        end_critical_section(S_SESSION_TABLE);
        if (killed > 0)
                syslog(LOG_INFO, "Scheduled %d idle sessions for termination\n", killed);
        if (longrunners > 0)
-               syslog(LOG_INFO, "Didn't terminate %d protected idle sessions;\n", killed);
+               syslog(LOG_INFO, "Didn't terminate %d protected idle sessions", longrunners);
 }
 
 
@@ -335,15 +336,16 @@ void terminate_all_sessions(void)
 void RemoveContext (CitContext *con)
 {
        const char *c;
-       if (con==NULL) {
-               syslog(LOG_ERR, "WARNING: RemoveContext() called with NULL!\n");
+       if (con == NULL) {
+               syslog(LOG_ERR, "WARNING: RemoveContext() called with NULL!");
                return;
        }
        c = con->ServiceName;
-       if (c == NULL)
+       if (c == NULL) {
                c = "WTF?";
-       syslog(LOG_DEBUG, "RemoveContext(%s) session %d\n", c, con->cs_pid);
-       cit_backtrace ();
+       }
+       syslog(LOG_DEBUG, "RemoveContext(%s) session %d", c, con->cs_pid);
+       cit_backtrace();
 
        /* Run any cleanup routines registered by loadable modules.
         * Note: We have to "become_session()" because the cleanup functions
@@ -355,7 +357,7 @@ void RemoveContext (CitContext *con)
        client_close();                         /* If the client is still connected, blow 'em away. */
        become_session(NULL);
 
-       syslog(LOG_NOTICE, "[%3d] Session ended.\n", con->cs_pid);
+       syslog(LOG_NOTICE, "[%3d] Session ended.", con->cs_pid);
 
        /* 
         * If the client is still connected, blow 'em away. 
@@ -363,7 +365,7 @@ void RemoveContext (CitContext *con)
         */
        if (con->client_socket > 0)
        {
-               syslog(LOG_NOTICE, "Closing socket %d\n", con->client_socket);
+               syslog(LOG_NOTICE, "Closing socket %d", con->client_socket);
                close(con->client_socket);
        }
 
@@ -379,7 +381,7 @@ void RemoveContext (CitContext *con)
                free(con->cached_msglist);
        }
 
-       syslog(LOG_DEBUG, "Done with RemoveContext()\n");
+       syslog(LOG_DEBUG, "Done with RemoveContext()");
 }
 
 
@@ -584,7 +586,7 @@ void context_cleanup(void)
                rem = ptr->next;
                --num_sessions;
 
-               syslog(LOG_DEBUG, "context_cleanup(): Purging session #%d %s\n", ptr->cs_pid, ptr->ServiceName);
+               syslog(LOG_DEBUG, "context_cleanup(): purging session %d\n", ptr->cs_pid);
                RemoveContext(ptr);
                free (ptr);
                ptr = rem;