Should program exit, When close() failed for O_RDONLY mode - Mailing list pgsql-hackers

From Lin, Cuiping
Subject Should program exit, When close() failed for O_RDONLY mode
Date
Msg-id 3134406ac1a94ed590347d341ce89e65@G08CNEXMBPEKD05.g08.fujitsu.local
Whole thread Raw
Responses Re: Should program exit, When close() failed for O_RDONLY mode  (Noah Misch <noah@leadboat.com>)
List pgsql-hackers
Hi,

 I find that most of the code does not check the return value of close(),  When open a file for reading(O_RDONLY).

 But I find that it checks the return value of close() in code "src/bin/pg_rewind/copy_fetch.c" When open a file for
reading(O_RDONLY).
 And it will call pg_fatal to cause premature exit.

 I think that when closing a read-only file fails, it shouid not exit  the program early.It  should ensure that the
programexecution is completed. 
 Like below:

・src/bin/pg_rewind/copy_fetch.c

before
--------------------------
rewind_copy_file_range
{
...
if (close(srcfd) != 0)
        pg_fatal("could not close file \"%s\": %m", srcpath); }
--------------------------

after
--------------------------
rewind_copy_file_range
{
...
    close(srcfd);
}
--------------------------

Regards,
--
Lin






pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Vacuum o/p with (full 1, parallel 0) option throwing an error
Next
From: Kyotaro Horiguchi
Date:
Subject: Re: Corruption during WAL replay