]> code.citadel.org Git - citadel.git/blobdiff - citadel/sysdep.c
* Shuffled around some of the housekeeping loop code
[citadel.git] / citadel / sysdep.c
index 3a011d641ce44f015900e6021981288fbd010c3f..b17a605b379f851a762e0e1ddde8f098e5ef6a62 100644 (file)
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <sys/socket.h>
-#include <sys/time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
 #include <limits.h>
 #include <netinet/in.h>
 #include <netdb.h>
@@ -78,8 +89,6 @@ int num_sessions = 0;                         /* Current number of sessions */
 fd_set masterfds;                              /* Master sockets etc. */
 int masterhighest;
 
-time_t last_timer = 0L;                                /* Last timer hook processing */
-
 static pthread_t initial_thread;               /* tid for main() thread */
 
 
@@ -264,6 +273,9 @@ void init_sysdep(void) {
 void begin_critical_section(int which_one)
 {
        /* lprintf(9, "begin_critical_section(%d)\n", which_one); */
+       /* ensure nobody ever tries to do a critical section within a
+          transaction; this could lead to deadlock. */
+       cdb_check_handles();
        pthread_mutex_lock(&Critters[which_one]);
 }
 
@@ -459,7 +471,6 @@ void client_write(char *buf, int nbytes)
        }
 
        while (bytes_written < nbytes) {
-               signal(SIGPIPE, SIG_IGN);
                retval = write(sock, &buf[bytes_written],
                        nbytes - bytes_written);
                if (retval < 1) {
@@ -978,7 +989,7 @@ int main(int argc, char **argv)
        /* Tell 'em who's in da house */
        lprintf(1,
 "\nMultithreaded message server for Citadel/UX\n"
-"Copyright (C) 1987-2000 by the Citadel/UX development team.\n"
+"Copyright (C) 1987-2001 by the Citadel/UX development team.\n"
 "Citadel/UX is free software, covered by the GNU General Public License, and\n"
 "you are welcome to change it and/or distribute copies of it under certain\n"
 "conditions.  There is absolutely no warranty for this software.  Please\n"
@@ -1144,7 +1155,7 @@ void *worker_thread(void *arg) {
                /* make doubly sure we're not holding any stale db handles
                 * which might cause a deadlock.
                 */
-               cdb_release_handles();
+               cdb_check_handles();
 
                begin_critical_section(S_I_WANNA_SELECT);
 SETUP_FD:      memcpy(&readfds, &masterfds, sizeof masterfds);
@@ -1282,12 +1293,7 @@ SETUP_FD:        memcpy(&readfds, &masterfds, sizeof masterfds);
 
                }
                dead_session_purge();
-               if ((time(NULL) - last_timer) > 60L) {
-                       last_timer = time(NULL);
-                       cdb_release_handles(); /* suggested by Justin Case */
-                       PerformSessionHooks(EVT_TIMER);
-               }
-
+               do_housekeeping();
                check_sched_shutdown();
        }