mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
Fix EOF behavior of ioReadSmall() to match ioRead().
If the buffer was not full at EOF then ioReadSmall() would get stuck in an infinite loop. Instead, return on EOF even if the buffer is not full. This is not an issue in released versions since ioReadSmall() is not being used. Also fix a comment typo.
This commit is contained in:
parent
4fb6384f10
commit
9a6afe3fc1
@ -252,7 +252,7 @@ ioReadSmall(IoRead *this, Buffer *buffer)
|
||||
{
|
||||
ioReadInternal(this, buffer, true);
|
||||
}
|
||||
// Else read as much data as is available. If is not enough we will try again later.
|
||||
// Else read as much data as is available. If it is not enough we will try again later.
|
||||
else
|
||||
{
|
||||
// Clear the internal output buffer since all data was copied already
|
||||
@ -263,7 +263,7 @@ ioReadSmall(IoRead *this, Buffer *buffer)
|
||||
}
|
||||
}
|
||||
}
|
||||
while (!bufFull(buffer));
|
||||
while (!bufFull(buffer) && !ioReadEof(this));
|
||||
|
||||
FUNCTION_TEST_RETURN(outputRemains - bufRemains(buffer));
|
||||
}
|
||||
|
@ -440,6 +440,7 @@ testRun(void)
|
||||
// Nothing left to read
|
||||
TEST_ERROR(ioReadLine(read), FileReadError, "unexpected eof while reading line");
|
||||
TEST_RESULT_UINT(ioRead(read, buffer), 0, "read buffer");
|
||||
TEST_RESULT_UINT(ioReadSmall(read, bufNew(55)), 0, "read buffer");
|
||||
|
||||
// Error if buffer is full and there is no linefeed
|
||||
ioBufferSizeSet(10);
|
||||
|
Loading…
Reference in New Issue
Block a user