/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at
if (sock_errno() == EINPROGRESS)
#else /* ifndef _WIN32 */
if (errno == EINPROGRESS)
if (sock_errno() == EINPROGRESS)
#else /* ifndef _WIN32 */
if (errno == EINPROGRESS)
sizeof(server.sin_addr), AF_INET);
privoxy_mutex_unlock(&resolver_mutex);
#else
sizeof(server.sin_addr), AF_INET);
privoxy_mutex_unlock(&resolver_mutex);
#else
- * Description : Accepts a connection on one of more socket. Sockets
- * must have been created using bind_port().
+ * Description : Accepts a connection on one of possibly multiple
+ * sockets. The socket(s) to check must have been
+ * created using bind_port().
- * 1 : csp = Client state, cfd, ip_addr_str, and
- * ip_addr_long will be set by this routine.
+ * 1 : csp = Client state, cfd, ip_addr_str, and
+ * ip_addr_long will be set by this routine.
* 2 : fds = File descriptors returned from bind_port
*
* Returns : when a connection is accepted, it returns 1 (TRUE).
* 2 : fds = File descriptors returned from bind_port
*
* Returns : when a connection is accepted, it returns 1 (TRUE).
- /* Wait for a connection on any socket. Return immediately if no socket is
- * listening. */
+ /*
+ * Wait for a connection on any socket.
+ * Return immediately if no socket is listening.
+ * XXX: Why not treat this as fatal error?
+ */
if (i >= MAX_LISTENING_SOCKETS)
{
log_error(LOG_LEVEL_ERROR,
if (i >= MAX_LISTENING_SOCKETS)
{
log_error(LOG_LEVEL_ERROR,
- "select(2) reported connected clients (number = %u, "
- "descriptor boundary = %u), but none found.",
- retval, max_selected_socket);
+ "select(2) reported connected clients (number = %u, "
+ "descriptor boundary = %u), but none found.",
+ retval, max_selected_socket);
if (!csp->ip_addr_str || retval)
{
log_error(LOG_LEVEL_ERROR, "Can not save csp->ip_addr_str: %s",
if (!csp->ip_addr_str || retval)
{
log_error(LOG_LEVEL_ERROR, "Can not save csp->ip_addr_str: %s",
while (gethostbyname_r(host, &result, hbuf,
HOSTENT_BUFFER_SIZE, &hostp, &thd_err)
&& (thd_err == TRY_AGAIN) && (dns_retries++ < MAX_DNS_RETRIES))
while (gethostbyname_r(host, &result, hbuf,
HOSTENT_BUFFER_SIZE, &hostp, &thd_err)
&& (thd_err == TRY_AGAIN) && (dns_retries++ < MAX_DNS_RETRIES))
log_error(LOG_LEVEL_ERROR,
"Timeout #%u while trying to resolve %s. Trying again.",
dns_retries, host);
log_error(LOG_LEVEL_ERROR,
"Timeout #%u while trying to resolve %s. Trying again.",
dns_retries, host);
while (NULL == (hostp = gethostbyname_r(host, &result,
hbuf, HOSTENT_BUFFER_SIZE, &thd_err))
&& (thd_err == TRY_AGAIN) && (dns_retries++ < MAX_DNS_RETRIES))
while (NULL == (hostp = gethostbyname_r(host, &result,
hbuf, HOSTENT_BUFFER_SIZE, &thd_err))
&& (thd_err == TRY_AGAIN) && (dns_retries++ < MAX_DNS_RETRIES))
log_error(LOG_LEVEL_ERROR,
"Timeout #%u while trying to resolve %s. Trying again.",
dns_retries, host);
log_error(LOG_LEVEL_ERROR,
"Timeout #%u while trying to resolve %s. Trying again.",
dns_retries, host);
privoxy_mutex_lock(&resolver_mutex);
while (NULL == (hostp = gethostbyname(host))
&& (h_errno == TRY_AGAIN) && (dns_retries++ < MAX_DNS_RETRIES))
privoxy_mutex_lock(&resolver_mutex);
while (NULL == (hostp = gethostbyname(host))
&& (h_errno == TRY_AGAIN) && (dns_retries++ < MAX_DNS_RETRIES))
log_error(LOG_LEVEL_ERROR,
"Timeout #%u while trying to resolve %s. Trying again.",
dns_retries, host);
log_error(LOG_LEVEL_ERROR,
"Timeout #%u while trying to resolve %s. Trying again.",
dns_retries, host);