From: Amos Jeffries Date: Sun, 27 Jun 2010 13:01:22 +0000 (+1200) Subject: correct use of host field. X-Git-Tag: take08~55^2~124^2~124 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=85d2870d5f68d925019b0cc2f5440a91ebd1eda5;p=thirdparty%2Fsquid.git correct use of host field. skip IPcache marking if host is empty, it is not always set. --- diff --git a/src/comm/ConnOpener.cc b/src/comm/ConnOpener.cc index 06cf7a3b9c..62b82e6b85 100644 --- a/src/comm/ConnOpener.cc +++ b/src/comm/ConnOpener.cc @@ -29,11 +29,13 @@ ConnOpener::~ConnOpener() void ConnOpener::setHost(const char * new_host) { - if (host == NULL) { - safe_free(host); // unset and erase if already set. - } else { + // unset and erase if already set. + if (host != NULL) + safe_free(host); + + // set the new one if given. + if (new_host != NULL) host = xstrdup(new_host); - } } const char * @@ -118,14 +120,16 @@ ConnOpener::start() fd_table[solo->fd].flags.open = 1; solo->local.SetPort(comm_local_port(solo->fd)); - ipcacheMarkGoodAddr(host, solo->remote); + if (host != NULL) + ipcacheMarkGoodAddr(host, solo->remote); callCallback(COMM_OK, 0); break; default: debugs(5, 5, HERE "FD " << solo->fd << ": * - try again"); fail_retries++; - ipcacheMarkBadAddr(host, solo->remote); + if (host != NULL) + ipcacheMarkBadAddr(host, solo->remote); #if USE_ICMP if (Config.onoff.test_reachability) netdbDeleteAddrNetwork(solo->remote);