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

Method Put2

src/cryptopp/network.cpp:422–476  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

420}
421
422size_t NetworkSink::Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
423{
424 if (m_eofState == EOF_DONE)
425 {
426 if (length || messageEnd)
427 throw Exception(Exception::OTHER_ERROR, "NetworkSink::Put2() being called after EOF had been sent");
428
429 return 0;
430 }
431
432 if (m_eofState > EOF_NONE)
433 goto EofSite;
434
435 {
436 if (m_skipBytes)
437 {
438 CRYPTOPP_ASSERT(length >= m_skipBytes);
439 inString += m_skipBytes;
440 length -= m_skipBytes;
441 }
442
443 m_buffer.Put(inString, length);
444
445 if (!blocking || m_buffer.CurrentSize() > m_autoFlushBound)
446 TimedFlush(0, 0);
447
448 size_t targetSize = messageEnd ? 0 : m_maxBufferSize;
449 if (blocking)
450 TimedFlush(INFINITE_TIME, targetSize);
451
452 if (m_buffer.CurrentSize() > targetSize)
453 {
454 CRYPTOPP_ASSERT(!blocking);
455 m_wasBlocked = true;
456 m_skipBytes += length;
457 size_t blockedBytes = UnsignedMin(length, m_buffer.CurrentSize() - targetSize);
458 return STDMAX<size_t>(blockedBytes, 1);
459 }
460
461 m_wasBlocked = false;
462 m_skipBytes = 0;
463 }
464
465 if (messageEnd)
466 {
467 m_eofState = EOF_PENDING_SEND;
468
469 EofSite:
470 TimedFlush(blocking ? INFINITE_TIME : 0, 0);
471 if (m_eofState != EOF_DONE)
472 return 1;
473 }
474
475 return 0;
476}
477
478lword NetworkSink::DoFlush(unsigned long maxTime, size_t targetSize)
479{

Callers 1

PumpMessages2Method · 0.45

Calls 4

UnsignedMinFunction · 0.85
ExceptionFunction · 0.70
PutMethod · 0.45
CurrentSizeMethod · 0.45

Tested by

no test coverage detected