From 252bbc8f88f980d977b721d157af74f7c2e8e83a Mon Sep 17 00:00:00 2001 From: Thomas Munro Date: Tue, 11 Feb 2020 17:10:25 +1300 Subject: [PATCH 3/3] Use pg_fstat_size() in walsender.c. This replaces couple of lseek() calls. --- 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..b94304a0e9 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_fstat_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 fstat file \"%s\": %m", path))); pq_sendint32(&buf, histfilelen); /* col2 len */ -- 2.23.0