From 9b3147cdaa9650eb242d1e98d46da1fc26df9e6b Mon Sep 17 00:00:00 2001 From: Thomas Munro Date: Thu, 13 Feb 2020 14:11:51 +1300 Subject: [PATCH 3/4] Remove lseek() calls from walsender.c. Use pg_file_size() instead. --- src/backend/replication/walsender.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index abb533b9d0..66c2233300 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -487,15 +487,11 @@ SendTimeLineHistory(TimeLineHistoryCmd *cmd) errmsg("could not open file \"%s\": %m", path))); /* Determine file length and send it to client */ - histfilelen = lseek(fd, 0, SEEK_END); + histfilelen = pg_file_size(fd); if (histfilelen < 0) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not seek to end of file \"%s\": %m", path))); - if (lseek(fd, 0, SEEK_SET) != 0) - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not seek to beginning of file \"%s\": %m", path))); + errmsg("could not get size of file \"%s\": %m", path))); pq_sendint32(&buf, histfilelen); /* col2 len */ -- 2.23.0