MCPcopy Create free account
hub / github.com/LUX-Core/lux / DoPump

Method DoPump

src/cryptopp/network.cpp:261–373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259}
260
261size_t NetworkSource::DoPump(lword &byteCount, bool blockingOutput, unsigned long maxTime, bool checkDelimiter, byte delimiter)
262{
263 NetworkReceiver &receiver = AccessReceiver();
264
265 lword maxSize = byteCount;
266 byteCount = 0;
267 bool forever = maxTime == INFINITE_TIME;
268 Timer timer(Timer::MILLISECONDS, forever);
269 BufferedTransformation *t = AttachedTransformation();
270
271 if (m_outputBlocked)
272 goto DoOutput;
273
274 while (true)
275 {
276 if (m_dataBegin == m_dataEnd)
277 {
278 if (receiver.EofReceived())
279 break;
280
281 if (m_waitingForResult)
282 {
283 if (receiver.MustWaitForResult() &&
284 !receiver.Wait(SaturatingSubtract(maxTime, timer.ElapsedTime()),
285 CallStack("NetworkSource::DoPump() - wait receive result", 0)))
286 break;
287
288 unsigned int recvResult = receiver.GetReceiveResult();
289#if CRYPTOPP_TRACE_NETWORK
290 OutputDebugString((IntToString((unsigned int)this) + ": Received " + IntToString(recvResult) + " bytes\n").c_str());
291#endif
292 m_dataEnd += recvResult;
293 m_waitingForResult = false;
294
295 if (!receiver.MustWaitToReceive() && !receiver.EofReceived() && m_dataEnd != m_buf.size())
296 goto ReceiveNoWait;
297 }
298 else
299 {
300 m_dataEnd = m_dataBegin = 0;
301
302 if (receiver.MustWaitToReceive())
303 {
304 if (!receiver.Wait(SaturatingSubtract(maxTime, timer.ElapsedTime()),
305 CallStack("NetworkSource::DoPump() - wait receive", 0)))
306 break;
307
308 receiver.Receive(m_buf+m_dataEnd, m_buf.size()-m_dataEnd);
309 m_waitingForResult = true;
310 }
311 else
312 {
313ReceiveNoWait:
314 m_waitingForResult = true;
315 // call Receive repeatedly as long as data is immediately available,
316 // because some receivers tend to return data in small pieces
317#if CRYPTOPP_TRACE_NETWORK
318 OutputDebugString((IntToString((unsigned int)this) + ": Receiving " + IntToString(m_buf.size()-m_dataEnd) + " bytes\n").c_str());

Callers

nothing calls this directly

Calls 14

AttachedTransformationFunction · 0.85
SaturatingSubtractFunction · 0.85
IntToStringFunction · 0.85
UnsignedMinFunction · 0.85
ElapsedTimeMethod · 0.80
MustWaitToReceiveMethod · 0.80
PutModifiable2Method · 0.80
CallStackClass · 0.70
EofReceivedMethod · 0.45
MustWaitForResultMethod · 0.45
WaitMethod · 0.45
GetReceiveResultMethod · 0.45

Tested by

no test coverage detected