CtdlThreadSelect no longer needs to be told which thread it is
authorDave West <davew@uncensored.citadel.org>
Fri, 7 Dec 2007 19:41:30 +0000 (19:41 +0000)
committerDave West <davew@uncensored.citadel.org>
Fri, 7 Dec 2007 19:41:30 +0000 (19:41 +0000)
do_command_loop now changes the name of the thread passing through it.

citadel/citserver.c
citadel/include/ctdl_module.h
citadel/sysdep.c

index d04ee38b231f2626536496f4daaa8c64f5708d86..088d6ceba92e1d1b6a30ef27d74951f2d429bd43 100644 (file)
@@ -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);
 }
 
 
index 932e0fe387428c71341190cc6745174ca928014c..dd8d96ca5720893bf4f3f59e75732d6e78019fa8 100644 (file)
@@ -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 */
index 67f47405257f7f375ed4367e54deb762ff7aabe2..6abc426e7391bad9879cd0b1872b1ba1869d2290 100644 (file)
@@ -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);