From: Andrew Deason Date: Thu, 30 May 2013 22:40:58 +0000 (-0500) Subject: ihandle: Fix fdInUseCount leak on EMFILE X-Git-Tag: upstream/1.6.6_pre2^2~64 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=2d1ed3a1108de01ac6a967daf3fc71646703b9f2;p=packages%2Fo%2Fopenafs.git ihandle: Fix fdInUseCount leak on EMFILE Here, we close closeFd, but currently we don't decrement fdInUseCount. Since we retry the open immediately afterwards, this means we can leak fdInUseCount references. For example, if we retry this 5 times and get EMFILE on each attempt, we will close 5 FDs, but not decrement fdInUseCount at all. To fix this, decrement fdInUseCounter when we close a file for EMFILE. Reviewed-on: http://gerrit.openafs.org/9967 Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit 48344381d7a87a3617ec14ffc9f2d9735805ada6) Change-Id: I03aee981c0b9663ac937c6165796f19366acec1e Reviewed-on: http://gerrit.openafs.org/10175 Reviewed-by: Derrick Brashear Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Stephan Wiesand --- diff --git a/src/vol/ihandle.c b/src/vol/ihandle.c index e09b4cbb8..80c9c229f 100644 --- a/src/vol/ihandle.c +++ b/src/vol/ihandle.c @@ -432,6 +432,9 @@ ih_open_retry: fdP->fd_fd = INVALID_FD; IH_UNLOCK; OS_CLOSE(closeFd); + IH_LOCK; + fdInUseCount -= 1; + IH_UNLOCK; goto ih_open_retry; } } else {