mirror of
https://github.com/bitinflow/server.git
synced 2026-03-13 13:35:53 +00:00
fix sending response when no client socket available
This commit is contained in:
17
server.js
17
server.js
@@ -98,14 +98,25 @@ function maybe_bounce(req, res, sock, head) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// happens when client upstream is disconnected
|
// happens when client upstream is disconnected (or disconnects)
|
||||||
|
// and the proxy iterates the waiting list and clears the callbacks
|
||||||
// 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
|
||||||
|
// TODO(roman) we could instead have a timeout above
|
||||||
|
// if no socket becomes available within some time,
|
||||||
|
// we just tell the user no resource available to service request
|
||||||
else if (!socket) {
|
else if (!socket) {
|
||||||
res.statusCode = 504;
|
if (res) {
|
||||||
res.end();
|
res.statusCode = 504;
|
||||||
|
res.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sock) {
|
||||||
|
sock.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
req.connection.destroy();
|
req.connection.destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user