mirror of
https://github.com/postgres/postgres.git
synced 2026-07-08 09:10:57 -04:00
Fix handling of copy_file_range() return value
Treat copy_file_range() return value of zero as an error: it indicates that no bytes could be copied (perhaps the source file is shorter than expected), and the existing retry loop would otherwise spin forever since nwritten would never reach BLCKSZ. The other uses of copy_file_range() in the tree don't have this problem. Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com> Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Reviewed-by: Yingying Chen <cyy9255@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/3208cf7a-c7f3-41eb-92f6-33cbeff4df40%40eisentraut.org
This commit is contained in:
parent
53482fcb94
commit
d36b728949
1 changed files with 3 additions and 0 deletions
|
|
@ -705,6 +705,9 @@ write_reconstructed_file(char *input_filename,
|
|||
if (wb < 0)
|
||||
pg_fatal("error while copying file range from \"%s\" to \"%s\": %m",
|
||||
input_filename, output_filename);
|
||||
else if (wb == 0)
|
||||
pg_fatal("unexpected end of file while copying file range from \"%s\" to \"%s\"",
|
||||
input_filename, output_filename);
|
||||
|
||||
nwritten += wb;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue