MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / readExact

Function readExact

src/Server/WebTerminalRequestHandler.cpp:136–149  ·  view source on GitHub ↗

Read exactly n bytes from the socket. If deadline_ns is non-zero, abort when the monotonic clock exceeds it.

Source from the content-addressed store, hash-verified

134/// Read exactly n bytes from the socket.
135/// If deadline_ns is non-zero, abort when the monotonic clock exceeds it.
136bool readExact(Poco::Net::StreamSocket & socket, char * buf, size_t n, UInt64 deadline_ns = 0)
137{
138 size_t total = 0;
139 while (total < n)
140 {
141 if (deadline_ns && clock_gettime_ns() > deadline_ns)
142 return false;
143 int received = socket.receiveBytes(buf + total, static_cast<int>(n - total));
144 if (received <= 0)
145 return false;
146 total += static_cast<size_t>(received);
147 }
148 return true;
149}
150
151struct WebSocketFrame
152{

Callers 1

readWebSocketFrameFunction · 0.85

Calls 2

clock_gettime_nsFunction · 0.85
receiveBytesMethod · 0.45

Tested by

no test coverage detected