Add timeout facility for event contexts
[citadel.git] / citadel / context.c
index 38e0d03f5eb130614105fc079f481106227d5f6a..576e9359c7da3cc9efeea5b6f6644d8e740f174f 100644 (file)
@@ -2,7 +2,7 @@
  * Citadel context management stuff.
  * Here's where we (hopefully) have all the code that manipulates contexts.
  *
- * Copyright (c) 1987-2011 by the citadel.org team
+ * Copyright (c) 1987-2015 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License, version 3.
@@ -22,6 +22,7 @@
 #include "locate_host.h"
 #include "context.h"
 #include "control.h"
+#include "config.h"
 
 int DebugSession = 0;
 
@@ -244,8 +245,8 @@ void terminate_idle_sessions(void)
        for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
                if (
                        (ccptr != CC)
-                       && (config.c_sleeping > 0)
-                       && (now - (ccptr->lastcmd) > config.c_sleeping)
+                       && (CtdlGetConfigLong("c_sleeping") > 0)
+                       && (now - (ccptr->lastcmd) > CtdlGetConfigLong("c_sleeping"))
                ) {
                        if (!ccptr->dont_term) {
                                ccptr->kill_me = KILLME_IDLE;
@@ -276,7 +277,12 @@ void terminate_all_sessions(void)
        for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
                if (ccptr->client_socket != -1)
                {
-                       CON_syslog(LOG_INFO, "terminate_all_sessions() is murdering %s", ccptr->curr_user);
+                       if (ccptr->IO != NULL) {
+                               CON_syslog(LOG_INFO, "terminate_all_sessions() is murdering %s IO[%ld]CC[%d]", ccptr->curr_user, ccptr->IO->ID, ccptr->cs_pid);
+                       }
+                       else {
+                               CON_syslog(LOG_INFO, "terminate_all_sessions() is murdering %s CC[%d]", ccptr->curr_user, ccptr->cs_pid);
+                       }
                        close(ccptr->client_socket);
                        ccptr->client_socket = -1;
                        killed++;
@@ -509,7 +515,7 @@ void begin_session(CitContext *con)
        *con->fake_hostname = '\0';
        *con->fake_roomname = '\0';
        *con->cs_clientinfo = '\0';
-       safestrncpy(con->cs_host, config.c_fqdn, sizeof con->cs_host);
+       safestrncpy(con->cs_host, CtdlGetConfigStr("c_fqdn"), sizeof con->cs_host);
        safestrncpy(con->cs_addr, "", sizeof con->cs_addr);
        con->cs_UDSclientUID = -1;
        con->cs_host[sizeof con->cs_host - 1] = 0;
@@ -561,7 +567,7 @@ void begin_session(CitContext *con)
        con->dl_is_net = 0;
 
        con->nologin = 0;
-       if (((config.c_maxsessions > 0)&&(num_sessions > config.c_maxsessions)) || CtdlWantSingleUser()) {
+       if (((CtdlGetConfigInt("c_maxsessions") > 0)&&(num_sessions > CtdlGetConfigInt("c_maxsessions"))) || CtdlWantSingleUser()) {
                con->nologin = 1;
        }