Commit 705060f1 authored by unknown's avatar unknown
Browse files

BUG #21858 Make sure retry when EINTR returns, which decreases memory leak chance.


ndb/src/common/util/File.cpp:
  Avoid memory leak when EINTR error returns. Even though a close-error happens, a ERROR message in out file
  is given, and this shouldn't affect the normally running.
parent 861425a0
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -123,12 +123,24 @@ bool
File_class::close()
{
  bool rc = true;
  int retval = 0;

  if (m_file != NULL)
  { 
    ::fflush(m_file);
    rc = (::fclose(m_file) == 0 ? true : false);
    m_file = NULL; // Try again?
    retval = ::fclose(m_file);
    while ( (retval != 0) && (errno == EINTR) ){
      retval = ::fclose(m_file);
    }
    if( retval == 0){
      rc = true;
    }
    else {
      rc = false;
      ndbout_c("ERROR: Close file error in File.cpp for %s",strerror(errno));
    }
  }  
  m_file = NULL;  

  return rc;
}