fix, add some introspection functionality

This commit is contained in:
Yakov Olkhovskiy 2024-05-20 14:15:47 +00:00
parent ee74d0de8c
commit 6378184c7f
3 changed files with 17 additions and 1 deletions

View File

@ -16,7 +16,7 @@ ReadBufferFromPocoSocketChunked::ReadBufferFromPocoSocketChunked(Poco::Net::Sock
{}
ReadBufferFromPocoSocketChunked::ReadBufferFromPocoSocketChunked(Poco::Net::Socket & socket_, const ProfileEvents::Event & read_event_, size_t buf_size)
: ReadBuffer(nullptr, 0), log(getLogger("Protocol")), buffer_socket(socket_, read_event_, buf_size)
: ReadBuffer(nullptr, 0), log(getLogger("Protocol")), peer_address(socket_.peerAddress()), our_address(socket_.address()), buffer_socket(socket_, read_event_, buf_size)
{
chassert(buf_size <= std::numeric_limits<decltype(chunk_left)>::max());
@ -28,6 +28,7 @@ void ReadBufferFromPocoSocketChunked::enableChunked()
{
chunked = true;
buffer_socket.position() = pos;
working_buffer.resize(offset());
}
bool ReadBufferFromPocoSocketChunked::poll(size_t timeout_microseconds)

View File

@ -18,6 +18,9 @@ public:
bool hasBufferedData() const { return hasPendingData() || buffer_socket.hasPendingData(); }
Poco::Net::SocketAddress peerAddress() { return peer_address; }
Poco::Net::SocketAddress ourAddress() { return our_address; }
protected:
bool startChunk();
bool nextChunk();
@ -25,6 +28,8 @@ protected:
private:
LoggerPtr log;
Poco::Net::SocketAddress peer_address;
Poco::Net::SocketAddress our_address;
ReadBufferFromPocoSocket buffer_socket;
bool chunked = false;
UInt32 chunk_left = 0; // chunk left to read from socket

View File

@ -54,6 +54,16 @@ protected:
WriteBufferFromPocoSocket::nextImpl();
}
Poco::Net::SocketAddress peerAddress()
{
return peer_address;
}
Poco::Net::SocketAddress ourAddress()
{
return our_address;
}
private:
LoggerPtr log;
bool chunked = false;