Browse files

misc refactor

  • Loading branch information...
1 parent 5f40df5 commit ba7cdf2021dcb757c0932d265bbe4fb00b4c77e6 @tj tj committed May 10, 2012
Showing with 8 additions and 5 deletions.
  1. +8 −5 lib/middleware/static.js
View
13 lib/middleware/static.js
@@ -228,13 +228,16 @@ var send = exports.send = function(req, res, next, options){
req.on('close', stream.destroy.bind(stream));
stream.pipe(res);
+ // clean up and flag as
+ // done for remaining events
+ function callback(err) {
+ done || fn(err);
+ done = true;
+ req.socket.removeListener('error', callback);
+ }
+
// callback
if (fn) {
- function callback(err) {
- done || fn(err);
- done = true;
- req.socket.removeListener("error", callback);
- }
req.on('close', callback);
req.socket.on('error', callback);
stream.on('error', callback);

0 comments on commit ba7cdf2

Please sign in to comment.