An independent reader from an MIOBuffer. More...
#include <I_IOBuffer.h>
Public Member Functions | |
char * | start () |
Start of unconsumed data. | |
char * | end () |
End of inuse area of the first block with unconsumed data. | |
int64_t | read_avail () |
Amount of data available across all of the IOBufferBlocks. | |
bool | is_read_avail_more_than (int64_t size) |
Check if there is more than size bytes available to read. | |
int | block_count () |
Number of IOBufferBlocks with data in the block list. | |
int64_t | block_read_avail () |
Amount of data available in the first buffer with data for this reader. | |
void | skip_empty_blocks () |
void | clear () |
Clears all fields in this IOBuffeReader, rendering it unusable. | |
void | reset () |
Instruct the reader to reset the IOBufferBlock list. | |
void | consume (int64_t n) |
Consume a number of bytes from this reader's IOBufferBlock list. | |
IOBufferReader * | clone () |
Create another reader with access to the same data as this IOBufferReader. | |
void | dealloc () |
Deallocate this reader. | |
IOBufferBlock * | get_current_block () |
Get a pointer to the first block with data. | |
bool | current_low_water () |
Consult this reader's MIOBuffer writable space. | |
bool | low_water () |
Queries the underlying MIOBuffer about. | |
bool | high_water () |
To see if the amount of data available to the reader is greater than the MIOBuffer's water mark. | |
inkcoreapi int64_t | memchr (char c, int64_t len=INT64_MAX, int64_t offset=0) |
Perform a memchr() across the list of IOBufferBlocks. | |
inkcoreapi int64_t | read (void *buf, int64_t len) |
Copies and consumes data. | |
inkcoreapi char * | memcpy (const void *buf, int64_t len=INT64_MAX, int64_t offset=0) |
Copy data but do not consume it. | |
char & | operator[] (int64_t i) |
Subscript operator. | |
MIOBuffer * | writer () const |
MIOBuffer * | allocated () const |
IOBufferReader () | |
Data Fields | |
MIOBufferAccessor * | accessor |
MIOBuffer * | mbuf |
Back pointer to this object's MIOBuffer. | |
Ptr< IOBufferBlock > | block |
int64_t | start_offset |
Offset beyond the shared start(). | |
int64_t | size_limit |
An independent reader from an MIOBuffer.
A reader for a set of IOBufferBlocks. The IOBufferReader represents the place where a given consumer of buffer data is reading from. It provides a uniform interface for easily accessing the data contained in a list of IOBufferBlocks associated with the IOBufferReader.
IOBufferReaders are the abstraction that determine when data blocks can be removed from the buffer.
Definition at line 540 of file I_IOBuffer.h.
IOBufferReader::IOBufferReader | ( | ) | [inline] |
Definition at line 787 of file I_IOBuffer.h.
MIOBuffer* IOBufferReader::allocated | ( | ) | const [inline] |
Definition at line 766 of file I_IOBuffer.h.
References mbuf.
TS_INLINE int IOBufferReader::block_count | ( | ) |
Number of IOBufferBlocks with data in the block list.
Returns the number of IOBufferBlocks on the block list with data remaining for this reader.
Definition at line 609 of file P_IOBuffer.h.
References block, and IOBufferBlock::next.
Referenced by MIOBuffer::max_block_count().
TS_INLINE int64_t IOBufferReader::block_read_avail | ( | ) |
Amount of data available in the first buffer with data for this reader.
Returns the number of unconsumed bytes of data available on the first IOBufferBlock with data for this reader.
Definition at line 600 of file P_IOBuffer.h.
References block, skip_empty_blocks(), and start_offset.
Referenced by NetVCTest::consume_and_check_bytes(), SocksProxy::mainEvent(), HTTPHdr::parse_req(), HTTPHdr::parse_resp(), read(), and HttpSM::state_read_push_response_header().
TS_INLINE void IOBufferReader::clear | ( | ) |
Clears all fields in this IOBuffeReader, rendering it unusable.
Drops the reference to the IOBufferBlock list, the accesor, MIOBuffer and resets this reader's state. You have to set those fields in order to use this object again.
Definition at line 697 of file P_IOBuffer.h.
References accessor, block, mbuf, size_limit, and start_offset.
Referenced by MIOBuffer::dealloc_reader().
TS_INLINE IOBufferReader * IOBufferReader::clone | ( | ) |
Create another reader with access to the same data as this IOBufferReader.
Allocates a new reader with the same state as this IOBufferReader. This means that the new reader will point to the same list of IOBufferBlocks and to the same buffer position as this reader.
Definition at line 1141 of file P_IOBuffer.h.
References MIOBuffer::clone_reader(), and mbuf.
Referenced by HttpSM::attach_client_session(), and TSIOBufferReaderClone().
TS_INLINE void IOBufferReader::consume | ( | int64_t | n | ) |
Consume a number of bytes from this reader's IOBufferBlock list.
Advances the current position in the IOBufferBlock list of this reader by n bytes.
n | number of bytes to consume. It must be less than or equal to read_avail(). |
Definition at line 653 of file P_IOBuffer.h.
References block, ink_assert, INT64_MAX, read_avail(), size_limit, and start_offset.
Referenced by CacheTestSM::check_buffer(), NetVCTest::consume_and_check_bytes(), HttpTunnel::copy_partial_post_data(), HttpClientSession::do_io_close(), HttpSM::do_setup_post_tunnel(), CacheTestSM::event_handler(), ChunkedHandler::generate_chunked_content(), FetchSM::get_info_from_buffer(), NullTransform::handle_event(), TransformTerminus::handle_event(), ShowCache::handleCacheEvent(), SocksProxy::mainEvent(), ObjectReloadCont::ObjectReloadEvent(), CacheVC::openWriteMain(), HTTPHdr::parse_req(), HTTPHdr::parse_resp(), FetchSM::process_fetch_read(), read(), HttpSM::server_transfer_init(), HttpSM::setup_push_transfer_to_cache(), CacheContinuation::setupReadBufTunnel(), HttpSM::state_read_push_response_header(), transfer_data(), RangeTransform::transform_to_range(), TSIOBufferReaderConsume(), vc_do_io_write(), and write_to_net_io().
TS_INLINE bool IOBufferReader::current_low_water | ( | ) |
Consult this reader's MIOBuffer writable space.
Queries the MIOBuffer associated with this reader about the amount of writable space available without adding any blocks on the buffer and returns true if it is less than the water mark.
Definition at line 570 of file P_IOBuffer.h.
References MIOBuffer::current_low_water(), and mbuf.
TS_INLINE void IOBufferReader::dealloc | ( | ) |
Deallocate this reader.
Removes and deallocates this reader from the underlying MIOBuffer. This IOBufferReader object must not be used after this call.
Definition at line 1147 of file P_IOBuffer.h.
References MIOBuffer::dealloc_reader(), and mbuf.
Referenced by HttpSM::setup_blind_tunnel(), and HttpSM::state_read_client_request_header().
TS_INLINE char * IOBufferReader::end | ( | ) |
End of inuse area of the first block with unconsumed data.
Returns a pointer to the end of the first block with unconsumed data for this reader. A NULL pointer indicates there are no blocks with unconsumed data for this reader.
Definition at line 591 of file P_IOBuffer.h.
References block, and skip_empty_blocks().
TS_INLINE IOBufferBlock * IOBufferReader::get_current_block | ( | ) |
Get a pointer to the first block with data.
Returns a pointer to the first IOBufferBlock in the block chain with data available for this reader
Definition at line 576 of file P_IOBuffer.h.
References block.
Referenced by HTTPHdr::parse_req(), HTTPHdr::parse_resp(), HttpSM::state_read_client_request_header(), TSIOBufferReaderStart(), and CacheContinuation::VCdataRead().
TS_INLINE bool IOBufferReader::high_water | ( | ) |
To see if the amount of data available to the reader is greater than the MIOBuffer's water mark.
Indicates whether the amount of data available to this reader exceeds the water mark for this reader's MIOBuffer.
Definition at line 564 of file P_IOBuffer.h.
References mbuf, read_avail(), and MIOBuffer::water_mark.
bool IOBufferReader::is_read_avail_more_than | ( | int64_t | size | ) | [inline] |
Check if there is more than size bytes available to read.
true
if more than size byte are available. Definition at line 638 of file P_IOBuffer.h.
References block, IOBufferBlock::next, IOBufferBlock::read_avail(), and start_offset.
Referenced by ProtocolProbeTrampoline::ioCompletionEvent(), and ChunkedHandler::process_chunked_content().
TS_INLINE bool IOBufferReader::low_water | ( | ) |
Queries the underlying MIOBuffer about.
Returns true if the amount of writable space after adding a block on the underlying MIOBuffer is less than its water mark. This function call may add blocks to the MIOBuffer (see MIOBuffer::low_water()).
Definition at line 558 of file P_IOBuffer.h.
References MIOBuffer::low_water(), and mbuf.
int64_t IOBufferReader::memchr | ( | char | c, | |
int64_t | len = INT64_MAX , |
|||
int64_t | offset = 0 | |||
) |
Perform a memchr() across the list of IOBufferBlocks.
Returns the offset from the current start point of the reader to the first occurence of character 'c' in the buffer.
c | character to look for. | |
len | number of characters to check. If len exceeds the number of bytes available on the buffer or INT64_MAX is passed in, the number of bytes available to the reader is used. It is independent of the offset value. | |
offset | number of the bytes to skip over before beginning the operation. |
Definition at line 209 of file IOBuffer.cc.
References block, IOBufferBlock::next, IOBufferBlock::read_avail(), IOBufferBlock::start(), and start_offset.
char * IOBufferReader::memcpy | ( | const void * | buf, | |
int64_t | len = INT64_MAX , |
|||
int64_t | offset = 0 | |||
) |
Copy data but do not consume it.
Copies 'len' bytes of data from the current buffer into the supplied buffer. The copy skips the number of bytes specified by 'offset' beyond the current point of the reader. It also takes into account the current start_offset value.
buf | in which to place the data. The pointer is modified after the call and points one position after the end of the data copied. | |
len | bytes to copy. If len exceeds the bytes available to the reader or INT64_MAX is passed in, the number of bytes available is used instead. No data is consumed from the reader in this operation. | |
offset | bytes to skip from the current position. The parameter is modified after the call. |
Definition at line 242 of file IOBuffer.cc.
References block, IOBufferBlock::next, IOBufferBlock::read_avail(), IOBufferBlock::start(), and start_offset.
Referenced by copy_from_buffer_reader(), proto_is_http2(), rcv_settings_frame(), read(), and TSIOBufferReaderCopy().
TS_INLINE char & IOBufferReader::operator[] | ( | int64_t | i | ) |
Subscript operator.
Returns a reference to the character at the specified position. You must ensure that it is within an appropriate range.
i | positions beyond the current point of the reader. It must be less than the number of the bytes available to the reader. |
Definition at line 673 of file P_IOBuffer.h.
References block, ink_assert, IOBufferBlock::next, IOBufferBlock::read_avail(), IOBufferBlock::start(), start_offset, and unlikely.
int64_t IOBufferReader::read | ( | void * | buf, | |
int64_t | len | |||
) |
Copies and consumes data.
Copies len bytes of data from the buffer into the supplied buffer, which must be allocated prior to the call and it must be at large enough for the requested bytes. Once the data is copied, it consumed from the reader.
buf | in which to place the data. | |
len | bytes to copy and consume. If 'len' exceeds the bytes available to the reader, the number of bytes available is used instead. |
Definition at line 188 of file IOBuffer.cc.
References block_read_avail(), consume(), memcpy(), read_avail(), and start().
Referenced by PrefetchBlaster::blastObject(), CacheTestSM::check_buffer(), NetTesterSM::handle_read(), and HtmlParser::ScanHtmlForURL().
TS_INLINE int64_t IOBufferReader::read_avail | ( | ) |
Amount of data available across all of the IOBufferBlocks.
Returns the number of unconsumed bytes of data available to this reader across all remaining IOBufferBlocks. It subtracts the current start_offset value from the total.
Definition at line 622 of file P_IOBuffer.h.
References block, INT64_MAX, IOBufferBlock::next, IOBufferBlock::read_avail(), size_limit, and start_offset.
Referenced by HttpTunnel::add_producer(), KeepAliveConn::append(), HttpClientSession::attach_server_session(), TransformVConnection::backlog(), HttpTunnelProducer::backlog(), PrefetchBlaster::blastObject(), CacheTestSM::check_buffer(), consume(), NetVCTest::consume_and_check_bytes(), HttpTunnel::copy_partial_post_data(), HttpClientSession::do_io_close(), INKVConnInternal::do_io_write(), HttpSM::do_setup_post_tunnel(), ClusterState::doIO(), VIO::done(), CacheTestSM::event_handler(), CacheTestSM::fill_buffer(), ChunkedHandler::generate_chunked_content(), FetchSM::get_info_from_buffer(), NullTransform::handle_event(), TransformTerminus::handle_event(), PrefetchTransform::handle_event(), HttpSM::handle_post_failure(), NetTesterSM::handle_read(), ShowCache::handleCacheEvent(), KeepAliveConn::handleEvent(), high_water(), KeepAliveConn::init(), SocksProxy::mainEvent(), MIOBuffer::max_read_avail(), ObjectReloadCont::ObjectReloadEvent(), CacheVC::openWriteMain(), FetchSM::process_fetch_read(), FetchSM::process_fetch_write(), HttpTunnel::producer_handler(), read(), RecursiveHttpGet::RecursiveHttpGetEvent(), ClusterVConnectionBase::reenable(), CacheVC::reenable(), HttpClientSession::release(), HttpSM::server_transfer_init(), HttpSM::setup_client_read_request_header(), HttpSM::setup_push_read_response_header(), HttpSM::setup_push_transfer_to_cache(), HttpSM::setup_server_read_response_header(), OneWayTunnel::startEvent(), OneWayMultiTunnel::startEvent(), HttpSM::state_read_push_response_header(), transfer_data(), RangeTransform::transform_to_range(), TSIOBufferReaderAvail(), PrefetchUrlBlaster::udpUrlBlaster(), ClusterHandler::valid_for_data_write(), and write_to_net_io().
TS_INLINE void IOBufferReader::reset | ( | ) |
Instruct the reader to reset the IOBufferBlock list.
Resets the reader to the point to the start of the block where new data will be written. After this call, the start_offset field is set to zero and the list of IOBufferBlocks is set using the associated MIOBuffer.
Definition at line 707 of file P_IOBuffer.h.
References MIOBuffer::_writer, block, mbuf, size_limit, and start_offset.
Referenced by MIOBuffer::alloc_accessor(), MIOBuffer::alloc_reader(), and MIOBuffer::reset().
TS_INLINE void IOBufferReader::skip_empty_blocks | ( | ) |
Definition at line 549 of file P_IOBuffer.h.
References block, and start_offset.
Referenced by block_read_avail(), end(), FetchSM::get_info_from_buffer(), start(), and TSIOBufferReaderStart().
TS_INLINE char * IOBufferReader::start | ( | ) |
Start of unconsumed data.
Returns a pointer to first unconsumed data on the buffer for this reader. A null pointer indicates no data is available. It uses the current start_offset value.
Definition at line 582 of file P_IOBuffer.h.
References block, skip_empty_blocks(), and start_offset.
Referenced by PrefetchBlaster::blastObject(), NetVCTest::consume_and_check_bytes(), SocksProxy::mainEvent(), HTTPHdr::parse_req(), HTTPHdr::parse_resp(), read(), HttpSM::state_read_push_response_header(), transfer_data(), and PrefetchUrlBlaster::udpUrlBlaster().
MIOBuffer* IOBufferReader::writer | ( | ) | const [inline] |
Definition at line 765 of file I_IOBuffer.h.
References mbuf.
Definition at line 768 of file I_IOBuffer.h.
Referenced by MIOBuffer::alloc_accessor(), MIOBuffer::alloc_reader(), clear(), MIOBuffer::clone_reader(), and MIOBuffer::dealloc_reader().
Definition at line 776 of file I_IOBuffer.h.
Referenced by block_count(), block_read_avail(), clear(), MIOBuffer::clone_reader(), consume(), ClusterState::doIO(), end(), get_current_block(), FetchSM::get_info_from_buffer(), MIOBuffer::init_readers(), is_read_avail_more_than(), UnixNetVConnection::load_buffer_and_write(), SSLNetVConnection::load_buffer_and_write(), memchr(), memcpy(), CacheVC::openWriteMain(), operator[](), read_avail(), MIOBuffer::remove_append(), reset(), skip_empty_blocks(), start(), TSIOBufferBlockReadAvail(), TSIOBufferBlockReadStart(), TSIOBufferReaderStart(), ClusterHandler::valid_for_data_write(), and MIOBuffer::write().
Back pointer to this object's MIOBuffer.
A pointer back to the MIOBuffer this reader is allocated from.
Definition at line 775 of file I_IOBuffer.h.
Referenced by HttpTunnel::add_producer(), MIOBuffer::alloc_accessor(), MIOBuffer::alloc_reader(), allocated(), HttpSM::attach_client_session(), clear(), clone(), MIOBuffer::clone_reader(), HttpTunnel::consumer_handler(), current_low_water(), dealloc(), TransformControl::handle_event(), high_water(), ChunkedHandler::init_by_action(), low_water(), MIOBufferAccessor::reader_for(), MIOBuffer::remove_append(), reset(), HttpSM::setup_client_read_request_header(), HttpSM::setup_push_read_response_header(), HttpSM::setup_server_read_response_header(), TSIOBufferReaderFree(), HttpSM::tunnel_handler_post_ua(), and writer().
int64_t IOBufferReader::size_limit |
Definition at line 785 of file I_IOBuffer.h.
Referenced by clear(), MIOBuffer::clone_reader(), consume(), read_avail(), and reset().
int64_t IOBufferReader::start_offset |
Offset beyond the shared start().
The start_offset is used in the calls that copy or consume data and is an offset at the beginning of the available data.
Definition at line 784 of file I_IOBuffer.h.
Referenced by block_read_avail(), clear(), MIOBuffer::clone_reader(), consume(), FetchSM::get_info_from_buffer(), is_read_avail_more_than(), UnixNetVConnection::load_buffer_and_write(), SSLNetVConnection::load_buffer_and_write(), memchr(), memcpy(), CacheVC::openWriteMain(), operator[](), read_avail(), MIOBuffer::remove_append(), reset(), skip_empty_blocks(), start(), TSIOBufferBlockReadAvail(), TSIOBufferBlockReadStart(), ClusterHandler::valid_for_data_write(), CacheContinuation::VCdataRead(), and MIOBuffer::write().