Skip to content

Commit df10ac6

Browse files
committed
Don't use elog() in src/port/pwrite.c.
Nothing broke because of this oversight yet, but it would fail to link if we tried to use pg_pwrite() in frontend code on a system that lacks pwrite(). Use an assertion instead. Also pgindent while here. Discussion: https://postgr.es/m/CA%2BhUKGL57RvoQsS35TVPnQoPYqbtBixsdRhynB8NpcUKpHTTtg%40mail.gmail.com
1 parent ee1b38f commit df10ac6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/port/pwrite.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
7070
return -1;
7171
return writev(fd, iov, iovcnt);
7272
#else
73-
ssize_t sum = 0;
74-
ssize_t part;
73+
ssize_t sum = 0;
74+
ssize_t part;
7575

7676
for (int i = 0; i < iovcnt; ++i)
7777
{
@@ -137,14 +137,14 @@ pg_pwritev_with_retry(int fd, const struct iovec *iov, int iovcnt, off_t offset)
137137
/* Are they all done? */
138138
if (iovcnt == 0)
139139
{
140-
if (part > 0)
141-
elog(ERROR, "unexpectedly wrote more than requested");
140+
/* We don't expect the kernel to write more than requested. */
141+
Assert(part == 0);
142142
break;
143143
}
144144

145145
/*
146-
* Move whatever's left to the front of our mutable copy and adjust the
147-
* leading iovec.
146+
* Move whatever's left to the front of our mutable copy and adjust
147+
* the leading iovec.
148148
*/
149149
Assert(iovcnt > 0);
150150
memmove(iov_copy, iov, sizeof(*iov) * iovcnt);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy