@@ -981,6 +981,8 @@ LruDelete(File file)
981
981
982
982
vfdP = & VfdCache [file ];
983
983
984
+ /* delete the vfd record from the LRU ring */
985
+ Delete (file );
984
986
985
987
if (vfdP -> fileFlags & PG_COMPRESSION )
986
988
{
@@ -1011,17 +1013,15 @@ LruDelete(File file)
1011
1013
vfdP -> fileName );
1012
1014
}
1013
1015
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 ;
1021
1016
-- nfile ;
1022
1017
}
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 ;
1025
1025
}
1026
1026
1027
1027
static void
@@ -1072,7 +1072,7 @@ LruInsert(File file)
1072
1072
vfdP -> fileMode );
1073
1073
if (vfdP -> fd < 0 )
1074
1074
{
1075
- DO_DB (elog (LOG , "re-open failed : %m" ));
1075
+ DO_DB (elog (LOG , "RE-OPEN FAILED : %m" ));
1076
1076
return -1 ;
1077
1077
}
1078
1078
else
@@ -1107,32 +1107,33 @@ LruInsert(File file)
1107
1107
else
1108
1108
{
1109
1109
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 )
1120
1118
{
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
+ }
1134
1135
}
1135
- }
1136
+ nfile += 1 ;
1136
1137
}
1137
1138
}
1138
1139
0 commit comments