Updated Branches: refs/heads/master becd1a2a2 -> 09ce8dc34
TS-2479: Don't output orphan log after failover sucessfully Don't output orphan log after failover successfully, BTW fix a potential issue about LogBuffer->m_references. ==NOTE==: Some logs maybe pending in the buffer of network thread when log server is down, in which case, the pending logs will be outputed to orphan file, and them will not be sent to the failover host. Signed-off-by: Yunkai Zhang <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/09ce8dc3 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/09ce8dc3 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/09ce8dc3 Branch: refs/heads/master Commit: 09ce8dc3434b92b00d99e0147e533a5f0bde8d7c Parents: becd1a2 Author: Yunkai Zhang <[email protected]> Authored: Mon Jan 6 23:00:14 2014 +0800 Committer: Yunkai Zhang <[email protected]> Committed: Tue Jan 7 11:58:25 2014 +0800 ---------------------------------------------------------------------- CHANGES | 2 ++ proxy/logging/LogHost.cc | 26 ++++++++++++-------------- proxy/logging/LogHost.h | 11 ++++++----- 3 files changed, 20 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/09ce8dc3/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index 8e36cf7..3f6442d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ -*- coding: utf-8 -*- Changes with Apache Traffic Server 4.2.0 + *) [TS-2479] Don't output orphan log after failover sucessfully. + *) [TS-2370] SSL proxy.config.ssl.server.honor_cipher_order is backwards. Changed the default setting and changed the meaning of it in the code. http://git-wip-us.apache.org/repos/asf/trafficserver/blob/09ce8dc3/proxy/logging/LogHost.cc ---------------------------------------------------------------------- diff --git a/proxy/logging/LogHost.cc b/proxy/logging/LogHost.cc index 89647aa..8ccf2e8 100644 --- a/proxy/logging/LogHost.cc +++ b/proxy/logging/LogHost.cc @@ -254,7 +254,6 @@ int LogHost::preproc_and_try_delete (LogBuffer *lb) { int ret = -1; - int bytes; if (lb == NULL) { Note("Cannot write LogBuffer to LogHost %s; LogBuffer is NULL", name()); @@ -277,16 +276,9 @@ LogHost::preproc_and_try_delete (LogBuffer *lb) ink_assert(m_log_collation_client_sm != NULL); } - // send log_buffer; orphan if necessary - bytes = m_log_collation_client_sm->send(lb); - if (bytes <= 0) { - orphan_write_and_try_delete(lb); -#if defined(LOG_BUFFER_TRACKING) - Debug("log-buftrak", "[%d]LogHost::preproc_and_try_delete - orphan write complete", - lb->header()->id); -#endif // defined(LOG_BUFFER_TRACKING) - return -1; - } + // send log_buffer; + if (m_log_collation_client_sm->send(lb) <= 0) + goto done; return 0; @@ -417,6 +409,8 @@ LogHostList::preproc_and_try_delete(LogBuffer * lb) { int ret; unsigned nr_host, nr; + bool need_orphan = true; + LogHost *available_host = NULL; ink_release_assert(lb->m_references == 0); @@ -425,19 +419,23 @@ LogHostList::preproc_and_try_delete(LogBuffer * lb) for (LogHost * host = first(); host && nr; host = next(host)) { LogHost *lh = host; + available_host = lh; do { ink_atomic_increment(&lb->m_references, 1); ret = lh->preproc_and_try_delete(lb); + need_orphan = need_orphan && (ret < 0); } while (ret < 0 && (lh = lh->failover_link.next)); - LogBuffer::destroy(lb); nr--; } - if (nr_host == 0) - delete lb; + if (need_orphan && available_host) { + ink_atomic_increment(&lb->m_references, 1); + available_host->orphan_write_and_try_delete(lb); + } + LogBuffer::destroy(lb); return 0; } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/09ce8dc3/proxy/logging/LogHost.h ---------------------------------------------------------------------- diff --git a/proxy/logging/LogHost.h b/proxy/logging/LogHost.h index 8442656..818233c 100644 --- a/proxy/logging/LogHost.h +++ b/proxy/logging/LogHost.h @@ -56,6 +56,12 @@ public: // int preproc_and_try_delete(LogBuffer * lb); + // + // write the given buffer data to orhpan file and + // try to delete it when its reference become zero. + // + void orphan_write_and_try_delete(LogBuffer * lb); + char const* name() const { return m_name ? m_name : "UNKNOWN"; } IpAddr const& ip_addr() const { return m_ip; } in_port_t port() const { return m_port; } @@ -70,11 +76,6 @@ public: private: void clear(); bool authenticated(); - // - // write the given buffer data to orhpan file and - // try to delete it when its reference become zero. - // - void orphan_write_and_try_delete(LogBuffer * lb); void create_orphan_LogFile_object(); private:
