This is an automated email from the ASF dual-hosted git repository. sorber pushed a commit to branch 6.2.x in repository https://git-dual.apache.org/repos/asf/trafficserver.git
commit 26dc2a86fcb8544888980d192aab6f8604bb34f6 Author: James Peach <[email protected]> AuthorDate: Wed Aug 10 14:10:17 2016 -0700 TS-4728: Return bool from LogHost boolean functions. (cherry picked from commit 0a12b2682cc718057ee33d0642dfe009c5574004) Conflicts: proxy/logging/LogHost.cc --- proxy/logging/LogConfig.cc | 2 +- proxy/logging/LogHost.cc | 39 ++++++++++++++++++++------------------- proxy/logging/LogHost.h | 6 +++--- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/proxy/logging/LogConfig.cc b/proxy/logging/LogConfig.cc index 2bff832..0590fc3 100644 --- a/proxy/logging/LogConfig.cc +++ b/proxy/logging/LogConfig.cc @@ -1471,7 +1471,7 @@ LogConfig::read_xml_log_config() while (failover_str = failover_tok.getNext(), failover_str != 0) { LogHost *lh = new LogHost(obj->get_full_filename(), obj->get_signature()); - if (lh->set_name_or_ipstr(failover_str)) { + if (lh->set_name_or_ipstr(failover_str) == false) { Warning("Could not set \"%s\" as collation host", host); delete lh; } else if (!prev) { diff --git a/proxy/logging/LogHost.cc b/proxy/logging/LogHost.cc index 796419f..a887721 100644 --- a/proxy/logging/LogHost.cc +++ b/proxy/logging/LogHost.cc @@ -94,12 +94,12 @@ LogHost::~LogHost() // - by specifying a hostname and a port (as separate arguments). // - by specifying an ip and a port (as separate arguments). // -int -LogHost::set_name_port(char *hostname, unsigned int pt) +bool +LogHost::set_name_port(const char *hostname, unsigned int pt) { if (!hostname || hostname[0] == 0) { Note("Cannot establish LogHost with NULL hostname"); - return 1; + return false; } clear(); // remove all previous state for this LogHost @@ -109,38 +109,38 @@ LogHost::set_name_port(char *hostname, unsigned int pt) Debug("log-host", "LogHost established as %s:%u", this->name(), this->port()); - create_orphan_LogFile_object(); - return 0; + m_orphan_file = make_orphan_logfile(this, m_object_filename); + return true; } -int -LogHost::set_ipstr_port(char *ipstr, unsigned int pt) +bool +LogHost::set_ipstr_port(const char *ipstr, unsigned int pt) { if (!ipstr || ipstr[0] == 0) { Note("Cannot establish LogHost with NULL ipstr"); - return 1; + return false; } clear(); // remove all previous state for this LogHost - if (0 != m_ip.load(ipstr)) + if (0 != m_ip.load(ipstr)) { Note("Log host failed to parse IP address %s", ipstr); + } + m_port = pt; ink_strlcpy(m_ipstr, ipstr, sizeof(m_ipstr)); m_name = ats_strdup(ipstr); Debug("log-host", "LogHost established as %s:%u", name(), pt); - create_orphan_LogFile_object(); - return 0; + m_orphan_file = make_orphan_logfile(this, m_object_filename); + return true; } -int -LogHost::set_name_or_ipstr(char *name_or_ip) +bool +LogHost::set_name_or_ipstr(const char *name_or_ip) { - int retVal = 1; - - if (name_or_ip && name_or_ip[0] != 0) { + if (name_or_ip && name_or_ip[0] != '\0') { ts::ConstBuffer addr, port; if (ats_ip_parse(ts::ConstBuffer(name_or_ip, strlen(name_or_ip)), &addr, &port) == 0) { uint16_t p = port ? atoi(port.data()) : Log::config->collation_port; @@ -149,13 +149,14 @@ LogHost::set_name_or_ipstr(char *name_or_ip) // string is followed by either a nul or a colon. n[addr.size()] = 0; if (AF_UNSPEC == ats_ip_check_characters(addr)) { - retVal = set_name_port(n, p); + return set_name_port(n, p); } else { - retVal = set_ipstr_port(n, p); + return set_ipstr_port(n, p); } } } - return retVal; + + return false; } bool diff --git a/proxy/logging/LogHost.h b/proxy/logging/LogHost.h index 7425d7c..5eb0d91 100644 --- a/proxy/logging/LogHost.h +++ b/proxy/logging/LogHost.h @@ -42,9 +42,9 @@ public: LogHost(const LogHost &); ~LogHost(); - int set_name_or_ipstr(char *name_or_ipstr); - int set_ipstr_port(char *ipstr, unsigned int port); - int set_name_port(char *hostname, unsigned int port); + bool set_name_or_ipstr(const char *name_or_ipstr); + bool set_ipstr_port(const char *ipstr, unsigned int port); + bool set_name_port(const char *hostname, unsigned int port); bool connected(bool ping); bool connect(); -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
