make done a no-op if not provided

This commit is contained in:
Roman Shtylman
2014-04-23 12:10:51 -04:00
parent 852023bd73
commit 7ecef6b69c

View File

@@ -60,17 +60,18 @@ function maybe_bounce(req, res, bounce) {
// get client port // get client port
client.next_socket(function(socket, done) { client.next_socket(function(socket, done) {
done = done || function() {};
// the request already finished or client disconnected // the request already finished or client disconnected
if (finished) { if (finished) {
return done(); return done();
} }
// happens when client upstream is disconnected // happens when client upstream is disconnected
// we gracefully inform the user and kill their conn // we gracefully inform the user and kill their conn
// without this, the browser will leave some connections open // without this, the browser will leave some connections open
// and try to use them again for new requests // and try to use them again for new requests
// we cannot have this as we need bouncy to assign the requests again // we cannot have this as we need bouncy to assign the requests again
if (!socket) { else if (!socket) {
res.statusCode = 504; res.statusCode = 504;
res.end(); res.end();
req.connection.destroy(); req.connection.destroy();