X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=jcc.c;h=6e667b21831e60a3b64652788d1d88547ca4adc4;hp=271b1d17965b9a1c7c39c6d0c6a9c8c09dcf8ebd;hb=2a3bacd32e282ea8a43a707019b089be9d57a08b;hpb=dde30f5e8bb12c63688330c97fde75493f92c09c diff --git a/jcc.c b/jcc.c index 271b1d17..6e667b21 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.357 2011/07/17 13:31:02 fabiankeil Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.361 2011/07/17 13:37:32 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -3339,43 +3339,44 @@ static jb_socket bind_port_helper(const char *haddr, int hport) int result; jb_socket bfd; - if (haddr == NULL) - { - log_error(LOG_LEVEL_INFO, "Listening on port %d on all IP addresses", - hport); - } - else - { - log_error(LOG_LEVEL_INFO, "Listening on port %d on IP address %s", - hport, haddr); - } - result = bind_port(haddr, hport, &bfd); if (result < 0) { + const char *bind_address = (NULL != haddr) ? haddr : "INADDR_ANY"; switch(result) { - case -3 : - log_error(LOG_LEVEL_FATAL, "can't bind to %s:%d: " - "There may be another Privoxy or some other " - "proxy running on port %d", - (NULL != haddr) ? haddr : "INADDR_ANY", hport, hport); + case -3: + log_error(LOG_LEVEL_FATAL, + "can't bind to %s:%d: There may be another Privoxy " + "or some other proxy running on port %d", + bind_address, hport, hport); - case -2 : - log_error(LOG_LEVEL_FATAL, "can't bind to %s:%d: " - "The hostname is not resolvable", - (NULL != haddr) ? haddr : "INADDR_ANY", hport); + case -2: + log_error(LOG_LEVEL_FATAL, + "can't bind to %s:%d: The hostname is not resolvable", + bind_address, hport); - default : + default: log_error(LOG_LEVEL_FATAL, "can't bind to %s:%d: %E", - (NULL != haddr) ? haddr : "INADDR_ANY", hport); + bind_address, hport); } /* shouldn't get here */ return JB_INVALID_SOCKET; } + if (haddr == NULL) + { + log_error(LOG_LEVEL_INFO, "Listening on port %d on all IP addresses", + hport); + } + else + { + log_error(LOG_LEVEL_INFO, "Listening on port %d on IP address %s", + hport, haddr); + } + return bfd; } @@ -3403,21 +3404,18 @@ static void bind_ports_helper(struct configuration_spec * config, { int i; - config->need_bind = 1; - for (i = 0; i < MAX_LISTENING_SOCKETS; i++) { - sockets[i] = JB_INVALID_SOCKET; - if (config->hport[i]) { sockets[i] = bind_port_helper(config->haddr[i], config->hport[i]); - if (JB_INVALID_SOCKET != sockets[i]) - { - config->need_bind = 0; - } + } + else + { + sockets[i] = JB_INVALID_SOCKET; } } + config->need_bind = 0; }