From 705060f10ccb6a0e3ce5899f7d8c2fdfc2a6a777 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 8 Oct 2006 11:24:53 +0800 Subject: 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. --- ndb/src/common/util/File.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'ndb') diff --git a/ndb/src/common/util/File.cpp b/ndb/src/common/util/File.cpp index 12626f29e7d..00741d3a576 100644 --- a/ndb/src/common/util/File.cpp +++ b/ndb/src/common/util/File.cpp @@ -123,13 +123,25 @@ 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; } -- cgit v1.2.1