From 294b6ce260a0fba6e9bb28e2a9d9f42d84044372 Mon Sep 17 00:00:00 2001 From: Dave West Date: Fri, 7 Dec 2007 19:41:30 +0000 Subject: [PATCH] CtdlThreadSelect no longer needs to be told which thread it is do_command_loop now changes the name of the thread passing through it. --- citadel/citserver.c | 9 ++++++++- citadel/include/ctdl_module.h | 2 +- citadel/sysdep.c | 8 ++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/citadel/citserver.c b/citadel/citserver.c index d04ee38b2..088d6ceba 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -990,12 +990,16 @@ void citproto_begin_session() { */ void do_command_loop(void) { char cmdbuf[SIZ]; - + char *old_name = NULL; + + old_name = CtdlThreadName("do_command_loop"); + time(&CC->lastcmd); memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */ if (client_getln(cmdbuf, sizeof cmdbuf) < 1) { lprintf(CTDL_ERR, "Client disconnected: ending session.\n"); CC->kill_me = 1; + CtdlThreadName(old_name); return; } @@ -1024,6 +1028,8 @@ void do_command_loop(void) { safestrncpy(CC->lastcmdname, cmdbuf, sizeof(CC->lastcmdname)); time(&CC->lastidle); } + + CtdlThreadName(cmdbuf); if ((strncasecmp(cmdbuf, "ENT0", 4)) && (strncasecmp(cmdbuf, "MESG", 4)) @@ -1395,6 +1401,7 @@ void do_command_loop(void) { /* Run any after-each-command routines registered by modules */ PerformSessionHooks(EVT_CMD); + CtdlThreadName(old_name); } diff --git a/citadel/include/ctdl_module.h b/citadel/include/ctdl_module.h index 932e0fe38..dd8d96ca5 100644 --- a/citadel/include/ctdl_module.h +++ b/citadel/include/ctdl_module.h @@ -126,7 +126,7 @@ double CtdlThreadGetWorkerAvg(void); double CtdlThreadGetLoadAvg(void); void CtdlThreadGC(void); void CtdlThreadStopAll(void); -int CtdlThreadSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout, struct CtdlThreadNode *self); +int CtdlThreadSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); void CtdlThreadAllocTSD(void); /* Macros to speed up getting outr thread */ diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 67f474052..6abc426e7 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -2041,13 +2041,13 @@ void ctdl_thread_internal_check_scheduled(void) /* * A warapper function for select so we can show a thread as blocked */ -int CtdlThreadSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout, struct CtdlThreadNode *self) +int CtdlThreadSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) { int ret; - ctdl_thread_internal_change_state(self, CTDL_THREAD_BLOCKED); + ctdl_thread_internal_change_state(CT, CTDL_THREAD_BLOCKED); ret = select(n, readfds, writefds, exceptfds, timeout); - ctdl_thread_internal_change_state(self, CTDL_THREAD_RUNNING); + ctdl_thread_internal_change_state(CT, CTDL_THREAD_RUNNING); return ret; } @@ -2205,7 +2205,7 @@ do_select: force_purge = 0; if (!CtdlThreadCheckStop()) { tv.tv_sec = 1; /* wake up every second if no input */ tv.tv_usec = 0; - retval = CtdlThreadSelect(highest + 1, &readfds, NULL, NULL, &tv, CT); + retval = CtdlThreadSelect(highest + 1, &readfds, NULL, NULL, &tv); } if (CtdlThreadCheckStop()) return(NULL); -- 2.39.2