do_command_loop now changes the name of the thread passing through it.
*/
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;
}
safestrncpy(CC->lastcmdname, cmdbuf, sizeof(CC->lastcmdname));
time(&CC->lastidle);
}
+
+ CtdlThreadName(cmdbuf);
if ((strncasecmp(cmdbuf, "ENT0", 4))
&& (strncasecmp(cmdbuf, "MESG", 4))
/* Run any after-each-command routines registered by modules */
PerformSessionHooks(EVT_CMD);
+ CtdlThreadName(old_name);
}
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 */
/*
* 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;
}
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);