Follow the OpenBSD port's lead and protect the resolve
authorFabian Keil <fk@fabiankeil.de>
Sat, 2 Sep 2006 15:36:42 +0000 (15:36 +0000)
committerFabian Keil <fk@fabiankeil.de>
Sat, 2 Sep 2006 15:36:42 +0000 (15:36 +0000)
functions on OpenBSD as well.

jbsockets.c
jcc.c
jcc.h

index ed5d597..0b7d8df 100644 (file)
@@ -1,4 +1,4 @@
-const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.38 2006/07/18 14:48:46 david__schmidt Exp $";
+const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.39 2006/08/03 02:46:41 david__schmidt Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
@@ -35,6 +35,9 @@ const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.38 2006/07/18 14:48:46 david_
  *
  * Revisions   :
  *    $Log: jbsockets.c,v $
  *
  * Revisions   :
  *    $Log: jbsockets.c,v $
+ *    Revision 1.39  2006/08/03 02:46:41  david__schmidt
+ *    Incorporate Fabian Keil's patch work:\rhttp://www.fabiankeil.de/sourcecode/privoxy/
+ *
  *    Revision 1.38  2006/07/18 14:48:46  david__schmidt
  *    Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
  *    with what was really the latest development (the v_3_0_branch branch)
  *    Revision 1.38  2006/07/18 14:48:46  david__schmidt
  *    Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
  *    with what was really the latest development (the v_3_0_branch branch)
@@ -260,11 +263,10 @@ const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.38 2006/07/18 14:48:46 david_
 
 #include "project.h"
 
 
 #include "project.h"
 
-#ifdef OSX_DARWIN
-#include <pthread.h>
+#if defined(OSX_DARWIN) || defined(__OpenBSD__)
 #include "jcc.h"
 /* jcc.h is for mutex semaphores only */
 #include "jcc.h"
 /* jcc.h is for mutex semaphores only */
-#endif /* def OSX_DARWIN */
+#endif /* defined(OSX_DARWIN) || defined(__OpenBSD__) */
 
 #include "jbsockets.h"
 #include "filters.h"
 
 #include "jbsockets.h"
 #include "filters.h"
@@ -746,7 +748,7 @@ int accept_connection(struct client_state * csp, jb_socket fd)
       {
          host = NULL;
       }
       {
          host = NULL;
       }
-#elif defined(OSX_DARWIN)
+#elif defined(OSX_DARWIN) || defined(__OpenBSD__)
       pthread_mutex_lock(&gethostbyaddr_mutex);
       host = gethostbyaddr((const char *)&server.sin_addr, 
                            sizeof(server.sin_addr), AF_INET);
       pthread_mutex_lock(&gethostbyaddr_mutex);
       host = gethostbyaddr((const char *)&server.sin_addr, 
                            sizeof(server.sin_addr), AF_INET);
@@ -831,7 +833,7 @@ unsigned long resolve_hostname_to_ip(const char *host)
       {
          hostp = NULL;
       }
       {
          hostp = NULL;
       }
-#elif OSX_DARWIN
+#elif defined(OSX_DARWIN) || defined(__OpenBSD__)
       pthread_mutex_lock(&gethostbyname_mutex);
       while ( NULL == (hostp = gethostbyname(host))
             && (h_errno == TRY_AGAIN) && (dns_retries++ < 10) )
       pthread_mutex_lock(&gethostbyname_mutex);
       while ( NULL == (hostp = gethostbyname(host))
             && (h_errno == TRY_AGAIN) && (dns_retries++ < 10) )
diff --git a/jcc.c b/jcc.c
index da261fe..7f7206e 100644 (file)
--- a/jcc.c
+++ b/jcc.c
@@ -1,4 +1,4 @@
-const char jcc_rcs[] = "$Id: jcc.c,v 1.97 2006/08/18 15:23:17 david__schmidt Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.98 2006/08/24 11:01:34 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
@@ -33,6 +33,10 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.97 2006/08/18 15:23:17 david__schmidt Exp
  *
  * Revisions   :
  *    $Log: jcc.c,v $
  *
  * Revisions   :
  *    $Log: jcc.c,v $
+ *    Revision 1.98  2006/08/24 11:01:34  fabiankeil
+ *    --user fix. Only use the user as group if no group is specified.
+ *    Solves BR 1492612. Thanks to Spinor S. and David Laight.
+ *
  *    Revision 1.97  2006/08/18 15:23:17  david__schmidt
  *    Windows service (re-)integration
  *
  *    Revision 1.97  2006/08/18 15:23:17  david__schmidt
  *    Windows service (re-)integration
  *
@@ -761,15 +765,20 @@ static int32 server_thread(void *data);
 #define sleep(N)  DosSleep(((N) * 100))
 #endif
 
 #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.
  */
 pthread_mutex_t gmtime_mutex;
 pthread_mutex_t localtime_mutex;
 #ifdef OSX_DARWIN
 /*
  * Hit OSX over the head with a hammer.  Protect all *_r functions.
  */
 pthread_mutex_t gmtime_mutex;
 pthread_mutex_t localtime_mutex;
+#endif /* def OSX_DARWIN */
+/*
+ * Protect only the resolve functions for OpenBSD.
+ */ 
 pthread_mutex_t gethostbyaddr_mutex;
 pthread_mutex_t gethostbyname_mutex;
 pthread_mutex_t gethostbyaddr_mutex;
 pthread_mutex_t gethostbyname_mutex;
-#endif /* def OSX_DARWIN */
+#endif /* defined(OSX_DARWIN) || defined(__OpenBSD__) */
 
 #ifdef FEATURE_PTHREAD
 pthread_mutex_t log_mutex;
 
 #ifdef FEATURE_PTHREAD
 pthread_mutex_t log_mutex;
@@ -2022,15 +2031,17 @@ int main(int argc, const char *argv[])
    InitWin32();
 #endif
 
    InitWin32();
 #endif
 
-#ifdef OSX_DARWIN
+#if defined(OSX_DARWIN) || defined(__OpenBSD__)
    /*
     * Prepare global mutex semaphores
     */
    /*
     * Prepare global mutex semaphores
     */
+#ifdef OSX_DARWIN
    pthread_mutex_init(&gmtime_mutex,0);
    pthread_mutex_init(&localtime_mutex,0);
    pthread_mutex_init(&gmtime_mutex,0);
    pthread_mutex_init(&localtime_mutex,0);
+#endif /* def OSX_DARWIN */
    pthread_mutex_init(&gethostbyaddr_mutex,0);
    pthread_mutex_init(&gethostbyname_mutex,0);
    pthread_mutex_init(&gethostbyaddr_mutex,0);
    pthread_mutex_init(&gethostbyname_mutex,0);
-#endif /* def OSX_DARWIN */
+#endif /* defined(OSX_DARWIN) || defined(__OpenBSD__) */
 
 #ifdef FEATURE_PTHREAD
    pthread_mutex_init(&log_mutex,0);
 
 #ifdef FEATURE_PTHREAD
    pthread_mutex_init(&log_mutex,0);
diff --git a/jcc.h b/jcc.h
index b821a7c..fba29af 100644 (file)
--- a/jcc.h
+++ b/jcc.h
@@ -1,6 +1,6 @@
 #ifndef JCC_H_INCLUDED
 #define JCC_H_INCLUDED
 #ifndef JCC_H_INCLUDED
 #define JCC_H_INCLUDED
-#define JCC_H_VERSION "$Id: jcc.h,v 1.14 2006/07/18 14:48:46 david__schmidt Exp $"
+#define JCC_H_VERSION "$Id: jcc.h,v 1.15 2006/09/02 10:24:30 fabiankeil Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.h,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.h,v $
  *
  * Revisions   :
  *    $Log: jcc.h,v $
  *
  * Revisions   :
  *    $Log: jcc.h,v $
+ *    Revision 1.15  2006/09/02 10:24:30  fabiankeil
+ *    Include pthread.h for OpenBSD to make Privoxy build again.
+ *
+ *    Tested shortly on OpenBSD 3.9 without problems, but the OpenBSD
+ *    port has additional patches to use the mutexes OSX_DARWIN needs,
+ *    and it should be investigated if they are still required for
+ *    reliable operation.
+ *
  *    Revision 1.14  2006/07/18 14:48:46  david__schmidt
  *    Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
  *    with what was really the latest development (the v_3_0_branch branch)
  *    Revision 1.14  2006/07/18 14:48:46  david__schmidt
  *    Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
  *    with what was really the latest development (the v_3_0_branch branch)
@@ -137,14 +145,13 @@ extern int g_terminate;
 
 #if defined(OSX_DARWIN) || defined(__OpenBSD__)
 #include <pthread.h>
 
 #if defined(OSX_DARWIN) || defined(__OpenBSD__)
 #include <pthread.h>
-#endif /* defined(OSX_DARWIN) || defined(__OpenBSD__) */
-
 #ifdef OSX_DARWIN
 extern pthread_mutex_t gmtime_mutex;
 extern pthread_mutex_t localtime_mutex;
 #ifdef OSX_DARWIN
 extern pthread_mutex_t gmtime_mutex;
 extern pthread_mutex_t localtime_mutex;
+#endif /* def OSX_DARWIN */
 extern pthread_mutex_t gethostbyaddr_mutex;
 extern pthread_mutex_t gethostbyname_mutex;
 extern pthread_mutex_t gethostbyaddr_mutex;
 extern pthread_mutex_t gethostbyname_mutex;
-#endif /* def OSX_DARWIN */
+#endif /* defined(OSX_DARWIN) || defined(__OpenBSD__) */
 
 #ifdef FEATURE_PTHREAD
 extern pthread_mutex_t log_mutex;
 
 #ifdef FEATURE_PTHREAD
 extern pthread_mutex_t log_mutex;