-const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.41 2006/11/13 19:05:51 fabiankeil Exp $";
+const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.42 2007/04/01 17:37:07 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
*
* Revisions :
* $Log: jbsockets.c,v $
+ * Revision 1.42 2007/04/01 17:37:07 fabiankeil
+ * - Add DNS retries for Solaris and other systems
+ * whose gethostbyname_r version takes five arguments.
+ * - Move maximum number of DNS retries into a macro.
+ *
* Revision 1.41 2006/11/13 19:05:51 fabiankeil
* Make pthread mutex locking more generic. Instead of
* checking for OSX and OpenBSD, check for FEATURE_PTHREAD
host = NULL;
}
#elif FEATURE_PTHREAD
- pthread_mutex_lock(&gethostbyaddr_mutex);
+ pthread_mutex_lock(&resolver_mutex);
host = gethostbyaddr((const char *)&server.sin_addr,
sizeof(server.sin_addr), AF_INET);
- pthread_mutex_unlock(&gethostbyaddr_mutex);
+ pthread_mutex_unlock(&resolver_mutex);
#else
host = gethostbyaddr((const char *)&server.sin_addr,
sizeof(server.sin_addr), AF_INET);
hostp = NULL;
}
#elif FEATURE_PTHREAD
- pthread_mutex_lock(&gethostbyname_mutex);
+ pthread_mutex_lock(&resolver_mutex);
while (NULL == (hostp = gethostbyname(host))
&& (h_errno == TRY_AGAIN) && (dns_retries++ < MAX_DNS_RETRIES))
{
"Timeout #%u while trying to resolve %s. Trying again.",
dns_retries, host);
}
- pthread_mutex_unlock(&gethostbyname_mutex);
+ pthread_mutex_unlock(&resolver_mutex);
#else
while (NULL == (hostp = gethostbyname(host))
&& (h_errno == TRY_AGAIN) && (dns_retries++ < MAX_DNS_RETRIES))
-const char jcc_rcs[] = "$Id: jcc.c,v 1.135 2007/05/24 17:03:50 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.136 2007/06/01 16:41:11 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
*
* Revisions :
* $Log: jcc.c,v $
+ * Revision 1.136 2007/06/01 16:41:11 fabiankeil
+ * Add forward-override{} to change the forwarding settings through
+ * action sections. This is mainly interesting to forward different
+ * clients differently (for example based on User-Agent or request
+ * origin).
+ *
* Revision 1.135 2007/05/24 17:03:50 fabiankeil
* - Let usage() mention the --chroot parameter.
* - Use read_socket() consistently and always leave
pthread_mutex_t log_mutex;
pthread_mutex_t log_init_mutex;
+#if !defined(HAVE_GETHOSTBYADDR_R) || !defined(HAVE_GETHOSTBYNAME_R)
+pthread_mutex_t resolver_mutex;
+#endif /* !defined(HAVE_GETHOSTBYADDR_R) || !defined(HAVE_GETHOSTBYNAME_R) */
+
#ifndef HAVE_GMTIME_R
pthread_mutex_t gmtime_mutex;
#endif /* ndef HAVE_GMTIME_R */
pthread_mutex_t localtime_mutex;
#endif /* ndef HAVE_GMTIME_R */
-#ifndef HAVE_GETHOSTBYADDR_R
-pthread_mutex_t gethostbyaddr_mutex;
-#endif /* ndef HAVE_GETHOSTBYADDR_R */
-
-#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 */
* have no gethostbyname_r, but gethostbyname is
* thread safe.
*/
+#if !defined(HAVE_GETHOSTBYADDR_R) || !defined(HAVE_GETHOSTBYNAME_R)
+ if (!err) err = pthread_mutex_init(&resolver_mutex, 0);
+#endif /* !defined(HAVE_GETHOSTBYADDR_R) || !defined(HAVE_GETHOSTBYNAME_R) */
+ /*
+ * XXX: should we use a single mutex for
+ * localtime() and gmtime() as well?
+ */
#ifndef HAVE_GMTIME_R
if (!err) err = pthread_mutex_init(&gmtime_mutex, 0);
#endif /* ndef HAVE_GMTIME_R */
if (!err) err = pthread_mutex_init(&localtime_mutex, 0);
#endif /* ndef HAVE_GMTIME_R */
-#ifndef HAVE_GETHOSTBYADDR_R
- if (!err) err = pthread_mutex_init(&gethostbyaddr_mutex, 0);
-#endif /* ndef HAVE_GETHOSTBYADDR_R */
-
-#ifndef HAVE_GETHOSTBYNAME_R
- if (!err) err = pthread_mutex_init(&gethostbyname_mutex, 0);
-#endif /* ndef HAVE_GETHOSTBYNAME_R */
-
#ifndef HAVE_RANDOM
if (!err) err = pthread_mutex_init(&rand_mutex, 0);
#endif /* ndef HAVE_RANDOM */
#ifndef JCC_H_INCLUDED
#define JCC_H_INCLUDED
-#define JCC_H_VERSION "$Id: jcc.h,v 1.20 2006/12/26 17:31:41 fabiankeil Exp $"
+#define JCC_H_VERSION "$Id: jcc.h,v 1.21 2007/04/22 13:18:06 fabiankeil Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.h,v $
*
* Revisions :
* $Log: jcc.h,v $
+ * Revision 1.21 2007/04/22 13:18:06 fabiankeil
+ * Keep the HTTP snippets local.
+ *
* Revision 1.20 2006/12/26 17:31:41 fabiankeil
* Mutex protect rand() if POSIX threading
* is used, warn the user if that's not possible
extern pthread_mutex_t localtime_mutex;
#endif /* ndef HAVE_GMTIME_R */
-#ifndef HAVE_GETHOSTBYADDR_R
-extern pthread_mutex_t gethostbyaddr_mutex;
-#endif /* ndef HAVE_GETHOSTBYADDR_R */
-
-#ifndef HAVE_GETHOSTBYNAME_R
-extern pthread_mutex_t gethostbyname_mutex;
-#endif /* ndef HAVE_GETHOSTBYNAME_R */
+#if !defined(HAVE_GETHOSTBYADDR_R) || !defined(HAVE_GETHOSTBYNAME_R)
+extern pthread_mutex_t resolver_mutex;
+#endif /* !defined(HAVE_GETHOSTBYADDR_R) || !defined(HAVE_GETHOSTBYNAME_R) */
#ifndef HAVE_RANDOM
extern pthread_mutex_t rand_mutex;