mirror of https://github.com/Icinga/icinga2.git
Merge pull request #9736 from Icinga/stream-read-allow_partial
Stream#Read(): remove de facto unused param allow_partial
This commit is contained in:
commit
48eb563ca0
|
@ -57,10 +57,8 @@ void FIFO::Optimize()
|
|||
/**
|
||||
* Implements IOQueue::Read.
|
||||
*/
|
||||
size_t FIFO::Read(void *buffer, size_t count, bool allow_partial)
|
||||
size_t FIFO::Read(void *buffer, size_t count)
|
||||
{
|
||||
ASSERT(allow_partial);
|
||||
|
||||
if (count > m_DataSize)
|
||||
count = m_DataSize;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
|
||||
~FIFO() override;
|
||||
|
||||
size_t Read(void *buffer, size_t count, bool allow_partial = false) override;
|
||||
size_t Read(void *buffer, size_t count) override;
|
||||
void Write(const void *buffer, size_t count) override;
|
||||
void Close() override;
|
||||
bool IsEof() const override;
|
||||
|
|
|
@ -23,12 +23,10 @@ void NetworkStream::Close()
|
|||
* @param count The number of bytes to read from the queue.
|
||||
* @returns The number of bytes actually read.
|
||||
*/
|
||||
size_t NetworkStream::Read(void *buffer, size_t count, bool allow_partial)
|
||||
size_t NetworkStream::Read(void *buffer, size_t count)
|
||||
{
|
||||
size_t rc;
|
||||
|
||||
ASSERT(allow_partial);
|
||||
|
||||
if (m_Eof)
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Tried to read from closed socket."));
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
|
||||
NetworkStream(Socket::Ptr socket);
|
||||
|
||||
size_t Read(void *buffer, size_t count, bool allow_partial = false) override;
|
||||
size_t Read(void *buffer, size_t count) override;
|
||||
void Write(const void *buffer, size_t count) override;
|
||||
|
||||
void Close() override;
|
||||
|
|
|
@ -21,7 +21,7 @@ StdioStream::~StdioStream()
|
|||
Close();
|
||||
}
|
||||
|
||||
size_t StdioStream::Read(void *buffer, size_t size, bool allow_partial)
|
||||
size_t StdioStream::Read(void *buffer, size_t size)
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ public:
|
|||
StdioStream(std::iostream *innerStream, bool ownsStream);
|
||||
~StdioStream() override;
|
||||
|
||||
size_t Read(void *buffer, size_t size, bool allow_partial = false) override;
|
||||
size_t Read(void *buffer, size_t size) override;
|
||||
void Write(const void *buffer, size_t size) override;
|
||||
|
||||
void Close() override;
|
||||
|
|
|
@ -124,7 +124,7 @@ bool StreamReadContext::FillFromStream(const Stream::Ptr& stream, bool may_wait)
|
|||
if (stream->IsEof())
|
||||
break;
|
||||
|
||||
size_t rc = stream->Read(Buffer + Size, 4096, true);
|
||||
size_t rc = stream->Read(Buffer + Size, 4096);
|
||||
|
||||
Size += rc;
|
||||
count += rc;
|
||||
|
|
|
@ -60,10 +60,9 @@ public:
|
|||
* @param buffer The buffer where data should be stored. May be nullptr if you're
|
||||
* not actually interested in the data.
|
||||
* @param count The number of bytes to read from the queue.
|
||||
* @param allow_partial Whether to allow partial reads.
|
||||
* @returns The number of bytes actually read.
|
||||
*/
|
||||
virtual size_t Read(void *buffer, size_t count, bool allow_partial = false) = 0;
|
||||
virtual size_t Read(void *buffer, size_t count) = 0;
|
||||
|
||||
/**
|
||||
* Writes data to the stream.
|
||||
|
|
|
@ -25,12 +25,12 @@ BOOST_AUTO_TEST_CASE(io)
|
|||
BOOST_CHECK(fifo->GetAvailableBytes() == 5);
|
||||
|
||||
char buffer1[2];
|
||||
fifo->Read(buffer1, 2, true);
|
||||
fifo->Read(buffer1, 2);
|
||||
BOOST_CHECK(memcmp(buffer1, "he", 2) == 0);
|
||||
BOOST_CHECK(fifo->GetAvailableBytes() == 3);
|
||||
|
||||
char buffer2[5];
|
||||
size_t rc = fifo->Read(buffer2, 5, true);
|
||||
size_t rc = fifo->Read(buffer2, 5);
|
||||
BOOST_CHECK(rc == 3);
|
||||
BOOST_CHECK(memcmp(buffer2, "llo", 3) == 0);
|
||||
BOOST_CHECK(fifo->GetAvailableBytes() == 0);
|
||||
|
|
Loading…
Reference in New Issue