1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-06 13:46:51 +03:00

Use pg_pwrite() in more places.

This removes some lseek() system calls.

Author: Thomas Munro
Reviewed-by: Andres Freund
Discussion: https://postgr.es/m/CA%2BhUKGJ%2BoHhnvqjn3%3DHro7xu-YDR8FPr0FL6LF35kHRX%3D_bUzg%40mail.gmail.com
This commit is contained in:
Thomas Munro
2020-02-11 17:22:37 +13:00
parent 2102ba4b58
commit 701a51fd4e
4 changed files with 7 additions and 40 deletions

View File

@@ -1333,8 +1333,7 @@ AddToDataDirLockFile(int target_line, const char *str)
len = strlen(destbuffer);
errno = 0;
pgstat_report_wait_start(WAIT_EVENT_LOCK_FILE_ADDTODATADIR_WRITE);
if (lseek(fd, (off_t) 0, SEEK_SET) != 0 ||
(int) write(fd, destbuffer, len) != len)
if (pg_pwrite(fd, destbuffer, len, 0) != len)
{
pgstat_report_wait_end();
/* if write didn't set errno, assume problem is no disk space */