Avoid excessive getpeername(2) calls for zookeeper_log

This commit is contained in:
Azat Khuzhin 2021-08-27 00:41:06 +03:00
parent 5bb0a91f83
commit a63ef6b8eb
2 changed files with 4 additions and 1 deletions

View File

@ -387,6 +387,7 @@ void ZooKeeper::connect(
}
socket.connect(node.address, connection_timeout);
socket_address = socket.peerAddress();
socket.setReceiveTimeout(operation_timeout);
socket.setSendTimeout(operation_timeout);
@ -1255,7 +1256,7 @@ void ZooKeeper::logOperationIfNeeded(const ZooKeeperRequestPtr & request, const
{
elem.type = log_type;
elem.event_time = event_time;
elem.address = socket.peerAddress();
elem.address = socket_address;
elem.session_id = session_id;
maybe_zk_log->add(elem);
}

View File

@ -199,6 +199,8 @@ private:
Poco::Timespan operation_timeout;
Poco::Net::StreamSocket socket;
/// To avoid excessive getpeername(2) calls.
Poco::Net::SocketAddress socket_address;
std::optional<ReadBufferFromPocoSocket> in;
std::optional<WriteBufferFromPocoSocket> out;