[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: privoxy broken with latest i386 snap?
> threads are b0rked. backing out marc's changes to the following versions
> makes privoxy work again:
It seems that the changes only changed timing to allow an existing bug to
show up. Privoxy was hanging on DNS access as part of gethostby* calls
from multiple threads. Per POSIX get*by* is NOT thread safe. get*by*_r
would be, but we don't have them.
This patch to the privoxy port seems to resolve the problem. Please apply
and test. I *think* it will resolve the problem. I'm still testing.
Sometimes it took lots of effort to trigger the bug so if I'm wrong the
ptoblem could still exist.
Thanks,
// marc
$OpenBSD$
--- jbsockets.c.orig Sun May 26 16:41:27 2002
+++ jbsockets.c Thu Feb 13 13:44:58 2003
@@ -185,6 +185,7 @@ const char jbsockets_rcs[] = "$Id: jbsoc
#include "config.h"
+#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -710,8 +711,13 @@ int accept_connection(struct client_stat
host = NULL;
}
#else
- host = gethostbyaddr((const char *)&server.sin_addr,
- sizeof(server.sin_addr), AF_INET);
+ {
+ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+ pthread_mutex_lock(&mutex);
+ host = gethostbyaddr((const char *)&server.sin_addr,
+ sizeof(server.sin_addr), AF_INET);
+ pthread_mutex_unlock(&mutex);
+ }
#endif
if (host == NULL)
{
@@ -784,7 +790,12 @@ unsigned long resolve_hostname_to_ip(con
hostp = NULL;
}
#else
- hostp = gethostbyname(host);
+ {
+ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+ pthread_mutex_lock(&mutex);
+ hostp = gethostbyname(host);
+ pthread_mutex_unlock(&mutex);
+ }
#endif /* def HAVE_GETHOSTBYNAME_R_(6|5|3)_ARGS */
if (hostp == NULL)
{