Added Toby Lyward to the list of contributors
[privoxy.git] / jcc.c
diff --git a/jcc.c b/jcc.c
index 6184dc3..73cdbcb 100644 (file)
--- a/jcc.c
+++ b/jcc.c
@@ -1,4 +1,4 @@
-const char jcc_rcs[] = "$Id: jcc.c,v 1.101 2006/09/06 09:23:37 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.106 2006/11/06 19:58:23 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
@@ -33,6 +33,27 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.101 2006/09/06 09:23:37 fabiankeil Exp $"
  *
  * Revisions   :
  *    $Log: jcc.c,v $
+ *    Revision 1.106  2006/11/06 19:58:23  fabiankeil
+ *    Move pthread.h inclusion from jcc.c to jcc.h.
+ *    Fixes build on x86-freebsd1 (FreeBSD 5.4-RELEASE).
+ *
+ *    Revision 1.105  2006/11/06 14:26:02  fabiankeil
+ *    Don't exit after receiving the second SIGHUP on Solaris.
+ *
+ *    Fixes BR 1052235, but the same problem may exist on other
+ *    systems. Once 3.0.6 is out we should use sigset()
+ *    where available and see if it breaks anything.
+ *
+ *    Revision 1.104  2006/09/23 13:26:38  roro
+ *    Replace TABs by spaces in source code.
+ *
+ *    Revision 1.103  2006/09/21 12:54:43  fabiankeil
+ *    Fix +redirect{}. Didn't work with -fast-redirects.
+ *
+ *    Revision 1.102  2006/09/06 13:03:04  fabiankeil
+ *    Respond with 400 and a short text message
+ *    if the client tries to use Privoxy as FTP proxy.
+ *
  *    Revision 1.101  2006/09/06 09:23:37  fabiankeil
  *    Make number of retries in case of forwarded-connect problems
  *    a config file option (forwarded-connect-retries) and use 0 as
@@ -665,10 +686,6 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.101 2006/09/06 09:23:37 fabiankeil Exp $"
 #include <fcntl.h>
 #include <errno.h>
 
-#ifdef FEATURE_PTHREAD
-#include <pthread.h>
-#endif /* def FEATURE_PTHREAD */
-
 #ifdef _WIN32
 # ifndef FEATURE_PTHREAD
 #  ifndef STRICT
@@ -777,24 +794,25 @@ static int32 server_thread(void *data);
 #define sleep(N)  DosSleep(((N) * 100))
 #endif
 
-#if defined(OSX_DARWIN) || defined(__OpenBSD__)
-#ifdef OSX_DARWIN
-/*
- * Hit OSX over the head with a hammer.  Protect all *_r functions.
- */
+#ifdef FEATURE_PTHREAD
+pthread_mutex_t log_mutex;
+pthread_mutex_t log_init_mutex;
+
+#ifndef HAVE_GMTIME_R
 pthread_mutex_t gmtime_mutex;
+#endif /* ndef HAVE_GMTIME_R */
+
+#ifndef HAVE_LOCALTIME_R
 pthread_mutex_t localtime_mutex;
-#endif /* def OSX_DARWIN */
-/*
- * Protect only the resolve functions for OpenBSD.
- */ 
+#endif /* ndef HAVE_GMTIME_R */
+
+#ifndef HAVE_GETHOSTBYADDR_R
 pthread_mutex_t gethostbyaddr_mutex;
-pthread_mutex_t gethostbyname_mutex;
-#endif /* defined(OSX_DARWIN) || defined(__OpenBSD__) */
+#endif /* ndef HAVE_GETHOSTBYADDR_R */
 
-#ifdef FEATURE_PTHREAD
-pthread_mutex_t log_mutex;
-pthread_mutex_t log_init_mutex;
+#ifndef HAVE_GETHOSTBYNAME_R
+pthread_mutex_t gethostbyname_mutex;
+#endif /* ndef HAVE_GETHOSTBYNAME_R */
 #endif /* FEATURE_PTHREAD */
 
 #if defined(unix) || defined(__EMX__)
@@ -1235,8 +1253,7 @@ static void chat(struct client_state *csp)
 
           /* ..or a fast redirect kicked in */
 #ifdef FEATURE_FAST_REDIRECTS
-          || (((csp->action->flags & ACTION_FAST_REDIRECTS) != 0) &&
-                (NULL != (rsp = redirect_url(csp))))
+          || ( NULL != (rsp = redirect_url(csp)))
 #endif /* def FEATURE_FAST_REDIRECTS */
           ))
       )
@@ -1288,7 +1305,7 @@ static void chat(struct client_state *csp)
    while ( (csp->sfd = forwarded_connect(fwd, http, csp))
          && (errno == EINVAL) && (forwarded_connect_retries++ < max_forwarded_connect_retries))
    {
-               log_error(LOG_LEVEL_ERROR, "failed request #%u to connect to %s. Trying again.",
+      log_error(LOG_LEVEL_ERROR, "failed request #%u to connect to %s. Trying again.",
                 forwarded_connect_retries, http->hostport);
    }
 
@@ -2059,21 +2076,28 @@ int main(int argc, const char *argv[])
    InitWin32();
 #endif
 
-#if defined(OSX_DARWIN) || defined(__OpenBSD__)
+#ifdef FEATURE_PTHREAD
    /*
     * Prepare global mutex semaphores
     */
-#ifdef OSX_DARWIN
+   pthread_mutex_init(&log_mutex,0);
+   pthread_mutex_init(&log_init_mutex,0);
+
+#ifndef HAVE_GMTIME_R
    pthread_mutex_init(&gmtime_mutex,0);
+#endif /* ndef HAVE_GMTIME_R */
+
+#ifndef HAVE_LOCALTIME_R
    pthread_mutex_init(&localtime_mutex,0);
-#endif /* def OSX_DARWIN */
+#endif /* ndef HAVE_GMTIME_R */
+
+#ifndef HAVE_GETHOSTBYADDR_R
    pthread_mutex_init(&gethostbyaddr_mutex,0);
-   pthread_mutex_init(&gethostbyname_mutex,0);
-#endif /* defined(OSX_DARWIN) || defined(__OpenBSD__) */
+#endif /* ndef HAVE_GETHOSTBYADDR_R */
 
-#ifdef FEATURE_PTHREAD
-   pthread_mutex_init(&log_mutex,0);
-   pthread_mutex_init(&log_init_mutex,0);
+#ifndef HAVE_GETHOSTBYNAME_R
+   pthread_mutex_init(&gethostbyname_mutex,0);
+#endif /* ndef HAVE_GETHOSTBYNAME_R */
 #endif /* FEATURE_PTHREAD */
 
 #ifdef HAVE_RANDOM
@@ -2096,7 +2120,11 @@ int main(int argc, const char *argv[])
 
    for (idx = 0; catched_signals[idx] != 0; idx++)
    {
+#ifdef sun /* FIXME: Is it safe to check for HAVE_SIGSET instead? */ 
+      if (sigset(catched_signals[idx], sig_handler) == SIG_ERR)
+#else
       if (signal(catched_signals[idx], sig_handler) == SIG_ERR)
+#endif /* ifdef sun */
       {
          log_error(LOG_LEVEL_FATAL, "Can't set signal-handler for signal %d: %E", catched_signals[idx]);
       }