{
char *from;
Size nbytes;
+ Size nleft;
+ int written;
/* Need to seek in the file? */
if (openLogOff != startoffset)
/* OK to write the page(s) */
from = XLogCtl->pages + startidx * (Size) XLOG_BLCKSZ;
nbytes = npages * (Size) XLOG_BLCKSZ;
- errno = 0;
- if (write(openLogFile, from, nbytes) != nbytes)
+ nleft = nbytes;
+ do
{
- /* if write didn't set errno, assume no disk space */
- if (errno == 0)
- errno = ENOSPC;
- ereport(PANIC,
- (errcode_for_file_access(),
- errmsg("could not write to log file %s "
- "at offset %u, length %lu: %m",
- XLogFileNameP(ThisTimeLineID, openLogSegNo),
- openLogOff, (unsigned long) nbytes)));
- }
+ errno = 0;
+ written = write(openLogFile, from, nleft);
+ if (written <= 0)
+ {
+ if (errno == EINTR)
+ continue;
+ ereport(PANIC,
+ (errcode_for_file_access(),
+ errmsg("could not write to log file %s "
+ "at offset %u, length %lu: %m",
+ XLogFileNameP(ThisTimeLineID, openLogSegNo),
+ openLogOff, (unsigned long) nbytes)));
+ }
+ nleft -= written;
+ from += written;
+ } while (nleft > 0);
/* Update state for write */
openLogOff += nbytes;