@@ -67,7 +67,6 @@ static bool firstreport_after_bootup = false; // the rotated logs check should r
6767// Define a struct to hold the file descriptor and size
6868typedef struct
6969{
70- int fd ;
7170 off_t cf_map_size ;
7271 off_t rf_map_size ;
7372 off_t cf_file_size ;
@@ -966,11 +965,6 @@ static void freeFileDescriptor(FileDescriptor* fileDescriptor)
966965 }
967966 fileDescriptor -> cfaddr = NULL ;
968967 fileDescriptor -> rfaddr = NULL ;
969- if (fileDescriptor -> fd != -1 )
970- {
971- close (fileDescriptor -> fd );
972- fileDescriptor -> fd = -1 ;
973- }
974968 free (fileDescriptor );
975969 }
976970}
@@ -1119,7 +1113,6 @@ static FileDescriptor* getFileDeltaInMemMapAndSearch(const int fd, const off_t s
11191113
11201114 T2Debug ("Log file got rotated. Ignoring invalid mapping\n" );
11211115 close (tmp_fd );
1122- close (fd );
11231116 if (rd != -1 )
11241117 {
11251118 close (rd );
@@ -1147,13 +1140,11 @@ static FileDescriptor* getFileDeltaInMemMapAndSearch(const int fd, const off_t s
11471140 {
11481141 T2Debug ("Log file got rotated. Ignoring invalid mapping\n" );
11491142 close (tmp_fd );
1150- close (fd );
11511143 return NULL ;
11521144 }
11531145 addrrf = NULL ;
11541146 }
11551147 close (tmp_fd );
1156- close (fd );
11571148
11581149 if (addrcf == MAP_FAILED )
11591150 {
@@ -1196,7 +1187,6 @@ static FileDescriptor* getFileDeltaInMemMapAndSearch(const int fd, const off_t s
11961187 fileDescriptor -> rfaddr = NULL ;
11971188 }
11981189 fileDescriptor -> cfaddr = addrcf ;
1199- fileDescriptor -> fd = fd ;
12001190 fileDescriptor -> cf_map_size = main_fsize ;
12011191 fileDescriptor -> cf_file_size = sb .st_size ;
12021192 if (fileDescriptor -> rfaddr != NULL )
@@ -1283,12 +1273,6 @@ static int parseMarkerListOptimized(GrepSeekProfile *gsProfile, Vector * ip_vMar
12831273 prevfile = NULL ;
12841274 }
12851275
1286- if (fd != -1 )
1287- {
1288- close (fd );
1289- fd = -1 ;
1290- }
1291-
12921276 if (fileDescriptor != NULL )
12931277 {
12941278 freeFileDescriptor (fileDescriptor );
@@ -1306,14 +1290,16 @@ static int parseMarkerListOptimized(GrepSeekProfile *gsProfile, Vector * ip_vMar
13061290 }
13071291
13081292 fileDescriptor = getFileDeltaInMemMapAndSearch (fd , seek_value , logPath , log_file_for_this_iteration , check_rotated_logs );
1293+
1294+ if (fd != -1 )
1295+ {
1296+ close (fd );
1297+ fd = -1 ;
1298+ }
1299+
13091300 if (fileDescriptor == NULL )
13101301 {
13111302 T2Error ("Failed to get file descriptor for %s\n" , log_file_for_this_iteration );
1312- if (fd != -1 )
1313- {
1314- close (fd );
1315- fd = -1 ;
1316- }
13171303 continue ;
13181304 }
13191305 }
@@ -1338,12 +1324,6 @@ static int parseMarkerListOptimized(GrepSeekProfile *gsProfile, Vector * ip_vMar
13381324 prevfile = NULL ;
13391325 }
13401326
1341- if (fd != -1 )
1342- {
1343- close (fd );
1344- fd = -1 ;
1345- }
1346-
13471327 if (fileDescriptor != NULL )
13481328 {
13491329 freeFileDescriptor (fileDescriptor );
0 commit comments