Permalink
Browse files

Reset the EMFILE timeout value if no writes in 1s

  • Loading branch information...
1 parent f872132 commit 65ded5a2ba8ad756e2a6592c38e0670e2e95cb14 @isaacs isaacs committed Nov 6, 2010
Showing with 3 additions and 0 deletions.
  1. +3 −0 lib/utils/graceful-fs.js
@@ -6,6 +6,7 @@
// anything else.
var fs = require("fs")
, timeout = 0
+ , resetTimer
Object.keys(fs)
.forEach(function (i) {
@@ -25,6 +26,8 @@ function graceful (fn) { return function GRACEFUL () {
return setTimeout(function () {
GRACEFUL.apply(fs, args)
}, timeout ++)
+ if (resetTimer) clearTimeout(resetTimer)
+ resetTimer = setTimeout(function () { timeout = 0 }, 1000)
}
cb_.apply(null, arguments)
}

0 comments on commit 65ded5a

Please sign in to comment.