Replace opendir/closedir calls throughout the backend with AllocateDir
Tom Lane <tgl@sss.pgh.pa.us>
Replace opendir/closedir calls throughout the backend with AllocateDir and FreeDir routines modeled on the existing AllocateFile/FreeFile. Like the latter, these routines will avoid failing on EMFILE/ENFILE conditions whenever possible, and will prevent leakage of directory descriptors if an elog() occurs while one is open. Also, reduce PANIC to ERROR in MoveOfflineLogs() --- this is not critical code and there is no reason to force a DB restart on failure. All per recent trouble report from Olivier Hubaut.
Files
| Path | Change | +/− |
|---|---|---|
| contrib/dbsize/dbsize.c | modified | +3 −4 |
| src/backend/access/transam/slru.c | modified | +3 −5 |
| src/backend/access/transam/xlog.c | modified | +5 −7 |
| src/backend/storage/file/fd.c | modified | +109 −17 |
| src/include/storage/fd.h | modified | +12 −2 |
| src/port/copydir.c | modified | +6 −6 |