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

Method receiveBytes

src/IO/SilkFiberStreamSocketImpl.cpp:172–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170}
171
172int FiberStreamSocketImpl::receiveBytes(void * buffer, int length, int flags)
173{
174 if (flags != 0)
175 throw DB::Exception(
176 DB::ErrorCodes::LOGICAL_ERROR,
177 "Silk::FiberStreamSocketImpl::receiveBytes: non-zero flags ({}) not supported",
178 flags);
179
180 throttleRecv(static_cast<size_t>(length), getBlocking());
181
182 uint64_t bytes_read = 0;
183 silk::FiberScheduler::IoFuture future;
184 iovec iov{buffer, static_cast<size_t>(length)};
185 silk::FiberScheduler::read(sockfd(), &iov, 1, 0, &bytes_read, &future);
186
187 Poco::Timespan timeout = getReceiveTimeout();
188 int r = 0;
189 if (timeout.totalMicroseconds() > 0)
190 {
191 r = silk::FiberFuture::waitWithTimeout(
192 &future,
193 static_cast<uint64_t>(timeout.totalMicroseconds()) * 1000);
194 if (r == ETIMEDOUT)
195 {
196 future.cancel();
197 r = future.wait();
198 if (r == ECANCELED)
199 throw Poco::TimeoutException("Receive timed out", peerAddress().toString());
200 }
201 }
202 else
203 {
204 r = future.wait();
205 }
206
207 if (r)
208 error(r, "recv");
209
210 useRecvThrottlerBudget(static_cast<int>(bytes_read));
211
212 return static_cast<int>(bytes_read);
213}
214
215void FiberStreamSocketImpl::setBlocking(bool flag)
216{

Callers 10

TYPED_TESTFunction · 0.45
readWordMethod · 0.45
readExactFunction · 0.45
finishHandshakeMethod · 0.45
tryReceiveFunction · 0.45
receiveExactlyFunction · 0.45
TESTFunction · 0.45

Calls 7

errorFunction · 0.85
ExceptionClass · 0.70
readFunction · 0.50
totalMicrosecondsMethod · 0.45
cancelMethod · 0.45
waitMethod · 0.45
toStringMethod · 0.45

Tested by 3

TYPED_TESTFunction · 0.36
receiveExactlyFunction · 0.36
TESTFunction · 0.36