]> code.citadel.org Git - citadel.git/commitdiff
* Replaced sleep() with a function that sleeps using select() in order to
authorArt Cancro <ajc@citadel.org>
Fri, 7 Feb 2003 04:44:17 +0000 (04:44 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 7 Feb 2003 04:44:17 +0000 (04:44 +0000)
  avoid potential issues with SIGALRM.  Possible fix for weird behavior
  when running on a Macintosh.

webcit/ChangeLog
webcit/context_loop.c
webcit/tools.c
webcit/webcit.h
webcit/webserver.c

index 43ee2698b3a28f2db845ea8f2d1b5a87abfc4951..62412d29093ae77595f246a45a202c83f0f4952d 100644 (file)
@@ -1,4 +1,9 @@
 $Log$
+Revision 400.89  2003/02/07 04:44:17  ajc
+* Replaced sleep() with a function that sleeps using select() in order to
+  avoid potential issues with SIGALRM.  Possible fix for weird behavior
+  when running on a Macintosh.
+
 Revision 400.88  2003/01/29 22:32:07  ajc
 * Shuffled some code and comments around; minor cleanup
 
@@ -1261,4 +1266,3 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
-
index 8eddaea805023bdfabee0ce4d95c4761a58cee54..743c4f3839e683278f04493090e14445b17fd528 100644 (file)
@@ -63,7 +63,8 @@ void do_housekeeping(void)
                        /* Remove sessions flagged for kill */
                        if (sptr->killthis) {
 
-                               lprintf(3, "Destroying session\n");
+                               lprintf(3, "Destroying session %d\n",
+                                       sptr->wc_session);
 
                                /* remove session from linked list */
                                if (sptr == SessionList) {
@@ -101,7 +102,7 @@ BREAKOUT:   pthread_mutex_unlock(&SessionListMutex);
 void housekeeping_loop(void)
 {
        while (1) {
-               sleep(HOUSEKEEPING);
+               sleeeeeeeeeep(HOUSEKEEPING);
                do_housekeeping();
        }
 }
@@ -111,7 +112,7 @@ void housekeeping_loop(void)
  * Generate a unique WebCit session ID (which is not the same thing as the
  * Citadel session ID).
  *
- * FIX ... ensure that session number is truly unique
+ * FIXME ... ensure that session number is truly unique
  *
  */
 int GenerateSessionID(void)
index a38e86c795a0ebf5eb7ed98e2bbaec7f49425f3a..ec84ddf4bf21628d43788e6fc4660fbc49aea2ce 100644 (file)
@@ -377,3 +377,16 @@ void stripout(char *str, char leftboundary, char rightboundary) {
 }
 
 
+
+/*
+ * Replacement for sleep() that uses select() in order to avoid SIGALRM
+ */
+void sleeeeeeeeeep(int seconds)
+{
+       struct timeval tv;
+
+       tv.tv_sec = seconds;
+       tv.tv_usec = 0;
+       select(0, NULL, NULL, NULL, &tv);
+}
+
index 411ec9acaa23d5d96b6b55ee86555e28c3efb8a6..cd7bfc4ccc2eb71f1c30fc9d1d0e67bf8908ffd2 100644 (file)
@@ -388,3 +388,4 @@ void partstat_as_string(char *buf, icalproperty *attendee);
 extern char *months[];
 extern char *days[];
 void read_server_binary(char *buffer, size_t total_len);
+void sleeeeeeeeeep(int);
index 64bfd56855eee7b6710a7a955ef308ca1b54acd0..8fa50f66cef91fb90b2fbf0f4ea54fe4291f2502 100644 (file)
@@ -379,7 +379,7 @@ int lprintf(int loglevel, const char *format, ...)
                struct tm *tim;
 
                gettimeofday(&tv, NULL);
-               tim = localtime(&(tv.tv_sec));
+               tim = localtime((time_t *)&(tv.tv_sec));
 
                if (WC && WC->wc_session) {
                        fprintf(stderr,
@@ -387,14 +387,16 @@ int lprintf(int loglevel, const char *format, ...)
                                tim->tm_year + 1900, tim->tm_mon + 1,
                                tim->tm_mday, tim->tm_hour, tim->tm_min,
                                tim->tm_sec, (long)tv.tv_usec / 1000,
-                               pthread_self(), WC->wc_session, buf);
+                               (long)pthread_self(),
+                               WC->wc_session, buf);
                } else {
                        fprintf(stderr,
                                "%04d/%02d/%02d %2d:%02d:%02d.%03ld [%ld] %s",
                                tim->tm_year + 1900, tim->tm_mon + 1,
                                tim->tm_mday, tim->tm_hour, tim->tm_min,
                                tim->tm_sec, (long)tv.tv_usec / 1000,
-                               pthread_self(), buf);
+                               (long)pthread_self(),
+                               buf);
                }
                fflush(stderr);
        }