1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-03 20:02:46 +03:00

Reset properly errno before calling write()

6cb3372 enforces errno to ENOSPC when less bytes than what is expected
have been written when it is unset, though it forgot to properly reset
errno before doing a system call to write(), causing errno to
potentially come from a previous system call.

Reported-by: Tom Lane
Author: Michael Paquier
Reviewed-by: Tom Lane
Discussion: https://postgr.es/m/31797.1533326676@sss.pgh.pa.us
This commit is contained in:
Michael Paquier
2018-08-05 05:32:37 +09:00
parent aca2257410
commit afd5fde856
7 changed files with 10 additions and 0 deletions

View File

@ -2369,6 +2369,7 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn,
ondisk->size = sz;
errno = 0;
if (write(fd, rb->outbuf, ondisk->size) != ondisk->size)
{
int save_errno = errno;