From c4b7b7250a5f5951813219dcd2c2253027879dce Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 2 Jan 2024 13:21:39 -0500 Subject: [PATCH] Changes to server session timeouts. CLIENT_TIMEOUT was found in the header files but not used anywhere. Removed. dont_term was removed because it was not needed anywhere anymore. --- citadel/server/clientsocket.h | 3 --- citadel/server/context.c | 27 ++++++++------------------- citadel/server/context.h | 1 - 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/citadel/server/clientsocket.h b/citadel/server/clientsocket.h index 0fe45fa3e..aaa7590bf 100644 --- a/citadel/server/clientsocket.h +++ b/citadel/server/clientsocket.h @@ -13,6 +13,3 @@ int sock_getln(int *sock, char *buf, int bufsize); int CtdlSockGetLine(int *sock, StrBuf *Target, int nSec); int sock_puts(int *sock, char *buf); int socket_read_blob(int *Socket, StrBuf * Target, int bytes, int timeout); - -// Default timeout for client sessions -#define CLIENT_TIMEOUT 600 diff --git a/citadel/server/context.c b/citadel/server/context.c index f7eea71f0..f7b0448e7 100644 --- a/citadel/server/context.c +++ b/citadel/server/context.c @@ -57,7 +57,7 @@ int CtdlWantSingleUser(void) { int CtdlIsSingleUser(void) { if (want_single_user) { - /* check for only one context here */ + // check for only one context here if (num_sessions == 1) return 1; } @@ -184,7 +184,6 @@ void terminate_idle_sessions(void) { CitContext *ccptr; time_t now; int killed = 0; - int longrunners = 0; now = time(NULL); begin_critical_section(S_SESSION_TABLE); @@ -194,22 +193,14 @@ void terminate_idle_sessions(void) { && (CtdlGetConfigLong("c_sleeping") > 0) && (now - (ccptr->lastcmd) > CtdlGetConfigLong("c_sleeping")) ) { - if (!ccptr->dont_term) { - ccptr->kill_me = KILLME_IDLE; - ++killed; - } - else { - ++longrunners; - } + ccptr->kill_me = KILLME_IDLE; + ++killed; } } end_critical_section(S_SESSION_TABLE); if (killed > 0) { syslog(LOG_INFO, "context: scheduled %d idle sessions for termination", killed); } - if (longrunners > 0) { - syslog(LOG_INFO, "context: did not terminate %d protected idle sessions", longrunners); - } } @@ -220,8 +211,7 @@ void terminate_all_sessions(void) { begin_critical_section(S_SESSION_TABLE); for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) { - if (ccptr->client_socket != -1) - { + if (ccptr->client_socket != -1) { syslog(LOG_INFO, "context: terminate_all_sessions() is murdering %s CC[%d]", ccptr->curr_user, ccptr->cs_pid); close(ccptr->client_socket); ccptr->client_socket = -1; @@ -257,7 +247,7 @@ void RemoveContext(CitContext *con) { become_session(NULL); syslog(LOG_INFO, "context: session %d (%s) ended.", con->cs_pid, c); - /* If using AUTHMODE_LDAP, free the DN */ + // If using AUTHMODE_LDAP, free the DN if (con->ldap_dn) { free(con->ldap_dn); con->ldap_dn = NULL; @@ -432,7 +422,7 @@ void begin_session(CitContext *con) { con->ServiceName, con->cs_host, con->cs_addr, con->cs_UDSclientUID ); - /* Run any session startup routines registered by loadable modules */ + // Run any session startup routines registered by loadable modules PerformSessionHooks(EVT_START); } @@ -530,11 +520,12 @@ void dead_session_purge(int force) { } --num_sessions; - /* And put it on our to-be-destroyed list */ + // And put it on our to-be-destroyed list ptr2->next = rem; rem = ptr2; } //else if (ptr2->kill_me) { + // 2023: this was a source of segfaults but I think we fixed it //syslog(LOG_DEBUG, "context: session %d is timed out but non-idle", ptr->cs_pid); //} } @@ -574,7 +565,5 @@ void set_async_waiting(struct CitContext *ccptr) { CTDL_MODULE_INIT(session) { - if (!threading) { - } return "session"; } diff --git a/citadel/server/context.h b/citadel/server/context.h index 8eceac52e..8a83c5e8e 100644 --- a/citadel/server/context.h +++ b/citadel/server/context.h @@ -38,7 +38,6 @@ struct CitContext { CitContext *next; /* Link to next session in the list */ int cs_pid; /* session ID */ - int dont_term; /* for special activities like artv so we don't get killed */ double created; /* time of birth */ time_t lastcmd; /* time of last command executed */ time_t lastidle; /* For computing idle time */ -- 2.30.2