Small optimisation for CtdlThreadSelect(). Now takes a pointer to this
authorDave West <davew@uncensored.citadel.org>
Fri, 30 Nov 2007 19:18:28 +0000 (19:18 +0000)
committerDave West <davew@uncensored.citadel.org>
Fri, 30 Nov 2007 19:18:28 +0000 (19:18 +0000)
thread.

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

index c2a20630d9ac10bea526f4849ed5bdd1a52b5d32..7813514339e66d877ab6b2af707c54fa66e65409 100644 (file)
@@ -118,6 +118,8 @@ struct CtdlThreadNode *CtdlThreadSelf(void);
 int CtdlThreadGetCount(void);
 void CtdlThreadGC(void);
 void CtdlThreadStopAll(void);
+int CtdlThreadSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timeval *timeout, struct CtdlThreadNode *self);
+
 /* Macros to speed up getting outr thread */
 #define CT _this_cit_thread
 #define CT_PUSH() \
index 5f27ad681e353648ac1186acdec22dae9c0854e9..35a5ed0085462af73456ed37ebc02448e7a96b65 100644 (file)
@@ -1785,12 +1785,10 @@ struct CtdlThreadNode *CtdlThreadCreate(char *name, long flags, void *(*thread_f
 /*
  * 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, const struct timeval *timeout)
+int CtdlThreadSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timeval *timeout, struct CtdlThreadNode *self)
 {
-       struct CtdlThreadNode *self;
        int ret;
        
-       self = CtdlThreadSelf();
        ctdl_thread_internal_change_state(self, CTDL_THREAD_BLOCKED);
        ret = select(n, readfds, writefds, exceptfds, timeout);
        ctdl_thread_internal_change_state(self, CTDL_THREAD_RUNNING);
@@ -1973,7 +1971,7 @@ do_select:        force_purge = 0;
                if (!CtdlThreadCheckStop(CT)) {
                        tv.tv_sec = 1;          /* wake up every second if no input */
                        tv.tv_usec = 0;
-                       retval = CtdlThreadSelect(highest + 1, &readfds, NULL, NULL, &tv);
+                       retval = CtdlThreadSelect(highest + 1, &readfds, NULL, NULL, &tv, CT);
 //                     retval = select(highest + 1, &readfds, NULL, NULL, &tv);
                }