Mutex protect rand() if POSIX threading
[privoxy.git] / jcc.c
diff --git a/jcc.c b/jcc.c
index 2dc0718..76fa1c3 100644 (file)
--- a/jcc.c
+++ b/jcc.c
@@ -1,4 +1,4 @@
-const char jcc_rcs[] = "$Id: jcc.c,v 1.110 2006/12/13 14:52:53 etresoft Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.111 2006/12/23 16:15:06 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
@@ -33,6 +33,10 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.110 2006/12/13 14:52:53 etresoft Exp $";
  *
  * Revisions   :
  *    $Log: jcc.c,v $
+ *    Revision 1.111  2006/12/23 16:15:06  fabiankeil
+ *    Don't prevent core dumps by catching SIGABRT.
+ *    It's rude and makes debugging unreasonable painful.
+ *
  *    Revision 1.110  2006/12/13 14:52:53  etresoft
  *    Fix build failure on MacOS X. Global symbols can be either static or extern, but not both.
  *
@@ -844,6 +848,11 @@ pthread_mutex_t gethostbyaddr_mutex;
 #ifndef HAVE_GETHOSTBYNAME_R
 pthread_mutex_t gethostbyname_mutex;
 #endif /* ndef HAVE_GETHOSTBYNAME_R */
+
+#ifndef HAVE_RANDOM
+pthread_mutex_t rand_mutex;
+#endif /* ndef HAVE_RANDOM */
+
 #endif /* FEATURE_PTHREAD */
 
 #if defined(unix) || defined(__EMX__)
@@ -899,7 +908,7 @@ const char MISSING_DESTINATION_RESPONSE[] =
  * Function    :  sig_handler 
  *
  * Description :  Signal handler for different signals.
- *                Exit gracefully on ABRT, TERM and  INT
+ *                Exit gracefully on TERM and INT
  *                or set a flag that will cause the errlog
  *                to be reopened by the main thread on HUP.
  *
@@ -2069,9 +2078,7 @@ int main(int argc, const char *argv[])
 #endif
 {
    int argc_pos = 0;
-#ifdef HAVE_RANDOM
-   unsigned int random_seed;
-#endif /* ifdef HAVE_RANDOM */
+   int random_seed;
 #ifdef unix
    struct passwd *pw = NULL;
    struct group *grp = NULL;
@@ -2238,11 +2245,18 @@ int main(int argc, const char *argv[])
 #ifndef HAVE_GETHOSTBYNAME_R
    pthread_mutex_init(&gethostbyname_mutex,0);
 #endif /* ndef HAVE_GETHOSTBYNAME_R */
+
+#ifndef HAVE_RANDOM
+   pthread_mutex_init(&rand_mutex,0);
+#endif /* ndef HAVE_RANDOM */
+
 #endif /* FEATURE_PTHREAD */
 
+   random_seed = (int)time(NULL);
 #ifdef HAVE_RANDOM
-   random_seed = (unsigned int)time(NULL);
    srandom(random_seed);
+#else
+   srand(random_seed);
 #endif /* ifdef HAVE_RANDOM */
 
    /*