@@ -419,6 +419,7 @@ bool Glog::appendLogFile(uint8_t &maxRecursionDepth, time_t epochSeconds) {
419
419
if (--maxRecursionDepth <= 0 ) {
420
420
InternalError (" appendLogFile() reach recursion upper limit" );
421
421
m_cacheFile->closeFile ();
422
+ closeFile (fd, filepath.c_str ());
422
423
return false ;
423
424
}
424
425
return appendLogFile (maxRecursionDepth, epochSeconds);
@@ -450,13 +451,15 @@ bool Glog::appendLogFile(uint8_t &maxRecursionDepth, time_t epochSeconds) {
450
451
InternalError (" fail to truncate [%s] to size %zu, %s" , filepath.c_str (), mmapOffset + mmapSize,
451
452
::strerror (errno));
452
453
m_cacheFile->closeFile ();
454
+ closeFile (fd, filepath.c_str ());
453
455
return false ;
454
456
}
455
457
456
458
if (!GlogFile::zeroFillFile (fd, fileSize, copySize)) {
457
459
InternalError (" fail to zeroFile [%s] to size %zu, %s" , filepath.c_str (), mmapOffset + mmapSize,
458
460
strerror (errno));
459
461
m_cacheFile->closeFile ();
462
+ closeFile (fd, filepath.c_str ());
460
463
return false ;
461
464
}
462
465
@@ -465,6 +468,7 @@ bool Glog::appendLogFile(uint8_t &maxRecursionDepth, time_t epochSeconds) {
465
468
if (mmapPtr == MAP_FAILED) {
466
469
InternalError (" fail to mmap [%s], %s" , filepath.c_str (), strerror (errno));
467
470
m_cacheFile->closeFile ();
471
+ closeFile (fd, filepath.c_str ());
468
472
return false ;
469
473
}
470
474
@@ -473,6 +477,7 @@ bool Glog::appendLogFile(uint8_t &maxRecursionDepth, time_t epochSeconds) {
473
477
if (src == nullptr || src == MAP_FAILED) {
474
478
InternalError (" fail to get cache file [%s] mmap ptr" , filepath.c_str ());
475
479
m_cacheFile->closeFile ();
480
+ closeFile (fd, filepath.c_str ());
476
481
return false ;
477
482
}
478
483
memcpy ((uint8_t *) mmapPtr + dstOffset, src + headerSize, copySize);
@@ -493,6 +498,7 @@ bool Glog::appendLogFile(uint8_t &maxRecursionDepth, time_t epochSeconds) {
493
498
InternalError (" fail to truncate [%s] to size %zu, %s" , filepath.c_str (), fileSize + copySize,
494
499
::strerror (errno));
495
500
m_cacheFile->closeFile ();
501
+ closeFile (fd, filepath.c_str ());
496
502
return false ;
497
503
}
498
504
@@ -502,8 +508,11 @@ bool Glog::appendLogFile(uint8_t &maxRecursionDepth, time_t epochSeconds) {
502
508
// m_cacheFile->resetInternalState();
503
509
504
510
m_cacheFile->closeFile ();
511
+ closeFile (fd, filepath.c_str ());
505
512
if (::remove (m_cacheFile->getPath ().c_str ()) < 0 ) {
506
513
InternalError (" fail to remove file [%s] %s" , m_cacheFile->getPath ().c_str (), ::strerror (errno));
514
+ m_cacheFile->closeFile ();
515
+ closeFile (fd, filepath.c_str ());
507
516
return false ;
508
517
} else {
509
518
InternalDebug (" remove file [%s]" , m_cacheFile->getPath ().c_str ());
0 commit comments