Updated Branches:
  refs/heads/master 3fad79d75 -> 5b002b11c

TS-2122: Enlarge the 64KB limitation of log buffer size

The Logging module use uint16_t(LogBuffer->m_state.s.m_offset/byte_count) to
store log buffer size.

It's very dangerous for user, as there are not any warning when user
breaks the limitation.

In our environment, we set the log_buffer_size to 512KB(and set
max_entries_per_buffer to 1000), it make ATS crashing.

This patch enlarge the limitation from 64KB to 4GB by merging *offset* and
*byte_count* variables into one, so that we can use uint32_t to store the
buffer size.

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/c0354fb6
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/c0354fb6
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/c0354fb6

Branch: refs/heads/master
Commit: c0354fb69ecc4ab4ad922e87cc969159bfb76051
Parents: 3fad79d
Author: Yunkai Zhang <[email protected]>
Authored: Fri Aug 9 11:05:22 2013 +0800
Committer: Yunkai Zhang <[email protected]>
Committed: Fri Aug 9 14:29:37 2013 +0800

----------------------------------------------------------------------
 proxy/logging/LogBuffer.cc | 4 +---
 proxy/logging/LogBuffer.h  | 3 +--
 2 files changed, 2 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c0354fb6/proxy/logging/LogBuffer.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogBuffer.cc b/proxy/logging/LogBuffer.cc
index 18a569e..f81dffa 100644
--- a/proxy/logging/LogBuffer.cc
+++ b/proxy/logging/LogBuffer.cc
@@ -143,7 +143,6 @@ LogBuffer::LogBuffer(LogObject * owner, size_t size, size_t 
buf_align, size_t wr
 
   // initialize buffer state
   m_state.s.offset = hdr_size;
-  m_state.s.byte_count = hdr_size;
 
   // update the buffer id (m_id gets the old value)
   m_id = (uint32_t) ink_atomic_increment((pvint32) & M_ID, 1);
@@ -230,7 +229,6 @@ LogBuffer::LB_ResultCode LogBuffer::checkout_write(size_t * 
write_offset, size_t
           ++new_s.s.num_writers;
           new_s.s.offset += actual_write_size;
           ++new_s.s.num_entries;
-          new_s.s.byte_count += actual_write_size;
 
           ret_val = LB_OK;
         } else {
@@ -424,7 +422,7 @@ LogBuffer::update_header_data()
 
   if (m_unaligned_buffer) {
     m_header->entry_count = m_state.s.num_entries;
-    m_header->byte_count = m_state.s.byte_count;
+    m_header->byte_count = m_state.s.offset;
     m_header->high_timestamp = LogUtils::timestamp();
   }
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c0354fb6/proxy/logging/LogBuffer.h
----------------------------------------------------------------------
diff --git a/proxy/logging/LogBuffer.h b/proxy/logging/LogBuffer.h
index 191b3a5..8f3de6b 100644
--- a/proxy/logging/LogBuffer.h
+++ b/proxy/logging/LogBuffer.h
@@ -118,9 +118,8 @@ union LB_State
   int64_t ival;
   struct
   {
-    uint16_t offset;              // buffer should be <= 64KB
+    uint32_t offset;              // buffer offset(bytes in buffer)
     uint16_t num_entries;         // number of entries in buffer
-    uint16_t byte_count;          // bytes in buffer
     uint16_t full:1;              // not accepting more checkouts
     uint16_t num_writers:15;      // number of writers
   } s;

Reply via email to