Bug #21858 File_class::close() doesn't check the return value of close(2)
Submitted: 28 Aug 2006 5:58 Modified: 25 Jan 2007 4:15
Reporter: Stewart Smith Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:4.1,5.0,5.1 OS:
Assigned to: Guangbao Ni CPU Architecture:Any

[28 Aug 2006 5:58] Stewart Smith
Description:
In File_class::close(), the return value of close(2) is "checked" but doesn't let you ever retry.

According to POSIX (http://www.opengroup.org/onlinepubs/000095399/functions/close.html) - close can 
 return EINTR.

bool
File_class::close()
{
  bool rc = true;
  if (m_file != NULL)
  {
    ::fflush(m_file);
    rc = (::fclose(m_file) == 0 ? true : false);
    m_file = NULL; // Try again?
  }

  return rc;
}

How to repeat:
very difficult to hit this to get a file descriptor leak - but theoretically possible

Suggested fix:
audit places that use close and make sure they retry if EINTR
[26 Sep 2006 2:16] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/12507

ChangeSet@1.2535, 2006-09-26 10:14:55+08:00, gni@dev3-127.(none) +1 -0
  BUG#21858  Make sure retry when EINTR returns, which decreases memory leak chance.
[8 Oct 2006 3:25] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/13310

ChangeSet@1.2535, 2006-10-08 11:24:53+08:00, gni@dev3-127.(none) +1 -0
  BUG #21858  Make sure retry when EINTR returns, which decreases memory leak chance.
[8 Oct 2006 3:35] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/13311

ChangeSet@1.2258, 2006-10-08 11:35:03+08:00, gni@dev3-127.(none) +1 -0
  BUG #21858 Make sure retry when EINTR returns, which decreases memory leak chance.
[23 Oct 2006 1:58] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/14125

ChangeSet@1.2315, 2006-10-20 14:55:14+08:00, gni@dev3-127.(none) +1 -0
  BUG #21858 Make sure retry when EINTR returns, which decreases memory leak chance.
[4 Dec 2006 8:21] Martin Skold
Pushed to 5.1.14
[5 Dec 2006 14:02] Martin Skold
Pushed to 5.0.31
[24 Jan 2007 1:58] Tomas Ulin
pushed to 5.1.15
[25 Jan 2007 4:15] Jon Stephens
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html

Documented bug fix in 5.0.30 and 5.1.15 changelogs.