@@ -981,6 +981,8 @@ LruDelete(File file)
981981
982982vfdP = & VfdCache [file ];
983983
984+ /* delete the vfd record from the LRU ring */
985+ Delete (file );
984986
985987if (vfdP -> fileFlags & PG_COMPRESSION )
986988{
@@ -1011,17 +1013,15 @@ LruDelete(File file)
10111013vfdP -> fileName );
10121014}
10131015
1014- /*
1015- * Close the file. We aren't expecting this to fail; if it does, better
1016- * to leak the FD than to mess up our internal state.
1017- */
1018- if (close (vfdP -> fd ))
1019- elog (LOG ,"could not close file \"%s\": %m" ,vfdP -> fileName );
1020- vfdP -> fd = VFD_CLOSED ;
10211016-- nfile ;
10221017}
1023- /* delete the vfd record from the LRU ring */
1024- Delete (file );
1018+ /*
1019+ * Close the file. We aren't expecting this to fail; if it does, better
1020+ * to leak the FD than to mess up our internal state.
1021+ */
1022+ if (close (vfdP -> fd ))
1023+ elog (LOG ,"could not close file \"%s\": %m" ,vfdP -> fileName );
1024+ vfdP -> fd = VFD_CLOSED ;
10251025}
10261026
10271027static void
@@ -1072,7 +1072,7 @@ LruInsert(File file)
10721072vfdP -> fileMode );
10731073if (vfdP -> fd < 0 )
10741074{
1075- DO_DB (elog (LOG ,"re-open failed : %m" ));
1075+ DO_DB (elog (LOG ,"RE-OPEN FAILED : %m" ));
10761076return -1 ;
10771077}
10781078else
@@ -1107,32 +1107,33 @@ LruInsert(File file)
11071107else
11081108{
11091109
1110- /*
1111- * Seek to the right position. We need no special case for seekPos
1112- * equal to FileUnknownPos, as lseek() will certainly reject that
1113- * (thus completing the logic noted in LruDelete() that we will fail
1114- * to re-open a file if we couldn't get its seek position before
1115- * closing).
1116- */
1117- if (vfdP -> seekPos != (off_t )0 )
1118- {
1119- if (lseek (vfdP -> fd ,vfdP -> seekPos ,SEEK_SET )< 0 )
1110+ /*
1111+ * Seek to the right position. We need no special case for seekPos
1112+ * equal to FileUnknownPos, as lseek() will certainly reject that
1113+ * (thus completing the logic noted in LruDelete() that we will fail
1114+ * to re-open a file if we couldn't get its seek position before
1115+ * closing).
1116+ */
1117+ if (vfdP -> seekPos != (off_t )0 )
11201118{
1121- /*
1122- * If we fail to restore the seek position, treat it like an
1123- * open() failure.
1124- */
1125- int save_errno = errno ;
1126-
1127- elog (LOG ,"could not seek file \"%s\" after re-opening: %m" ,
1128- vfdP -> fileName );
1129- (void )close (vfdP -> fd );
1130- vfdP -> fd = VFD_CLOSED ;
1131- -- nfile ;
1132- errno = save_errno ;
1133- return -1 ;
1119+ if (lseek (vfdP -> fd ,vfdP -> seekPos ,SEEK_SET )< 0 )
1120+ {
1121+ /*
1122+ * If we fail to restore the seek position, treat it like an
1123+ * open() failure.
1124+ */
1125+ int save_errno = errno ;
1126+
1127+ elog (LOG ,"could not seek file \"%s\" after re-opening: %m" ,
1128+ vfdP -> fileName );
1129+ (void )close (vfdP -> fd );
1130+ vfdP -> fd = VFD_CLOSED ;
1131+ -- nfile ;
1132+ errno = save_errno ;
1133+ return -1 ;
1134+ }
11341135}
1135- }
1136+ nfile += 1 ;
11361137}
11371138}
11381139