MCPcopy Create free account
hub / github.com/apache/trafficserver / LogBuffer

Method LogBuffer

src/proxy/logging/LogBuffer.cc:112–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112LogBuffer::LogBuffer(const LogConfig *cfg, LogObject *owner, size_t size, size_t buf_align, size_t write_align)
113 : m_size(size), m_buf_align(buf_align), m_write_align(write_align), m_owner(owner), m_references(0)
114{
115 size_t hdr_size;
116
117 // create the buffer
118 //
119 int64_t alloc_size = size + buf_align;
120
121 if (alloc_size <= BUFFER_SIZE_FOR_INDEX(cfg->logbuffer_max_iobuf_index)) {
122 m_buffer_fast_allocator_size = buffer_size_to_index(alloc_size, cfg->logbuffer_max_iobuf_index);
123 m_unaligned_buffer = static_cast<char *>(ioBufAllocator[m_buffer_fast_allocator_size].alloc_void());
124 } else {
125 m_buffer_fast_allocator_size = -1;
126 m_unaligned_buffer = static_cast<char *>(ats_malloc(alloc_size));
127 }
128 m_buffer = static_cast<char *>(align_pointer_forward(m_unaligned_buffer, buf_align));
129
130 // add the header
131 hdr_size = _add_buffer_header(cfg);
132
133 // initialize buffer state
134 m_state.s.offset = hdr_size;
135
136 // update the buffer id (m_id gets the old value)
137 m_id = static_cast<uint32_t>(ink_atomic_increment(&M_ID, 1));
138
139 m_expiration_time = LogUtils::timestamp() + cfg->max_secs_per_buffer;
140
141 Dbg(dbg_ctl_log_logbuffer, "[%p] Created buffer %u for %s at address %p, size %d", this_ethread(), m_id,
142 m_owner->get_base_filename(), m_buffer, (int)size);
143}
144
145LogBuffer::LogBuffer(LogObject *owner, LogBufferHeader *header)
146 : m_unaligned_buffer(nullptr),

Callers

nothing calls this directly

Calls 8

buffer_size_to_indexFunction · 0.85
ats_mallocFunction · 0.85
align_pointer_forwardFunction · 0.85
ink_atomic_incrementFunction · 0.85
this_ethreadFunction · 0.85
get_base_filenameMethod · 0.80
timestampFunction · 0.50
alloc_voidMethod · 0.45

Tested by

no test coverage detected