Prevented server crashes caused by header write errors. Also adapted RedBrick patches to OrangeCircle
This commit is contained in:
parent
d75c6ce955
commit
1680398db2
1 changed files with 6 additions and 3 deletions
9
index.js
9
index.js
|
@ -89,6 +89,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
|||
}
|
||||
|
||||
var abheaders = JSON.parse(JSON.stringify(bheaders));
|
||||
var socket = {};
|
||||
|
||||
function executeSCGI(req, res, dh, nEnv) {
|
||||
// Function to execute SCGI scripts
|
||||
|
@ -152,6 +153,8 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
|||
res.writeHead(code, msg, bheaderso);
|
||||
res.write(buffer.substr(headerendline + eol.length), "latin1");
|
||||
} catch (ex) {
|
||||
socket.removeAllListeners("data");
|
||||
socket.removeAllListeners("end");
|
||||
if (!callServerError) {
|
||||
res.writeHead(500);
|
||||
res.end(ex.stack);
|
||||
|
@ -163,13 +166,13 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
|||
} else {
|
||||
if (cned && !res.finished) {
|
||||
res.write(data);
|
||||
interpreter.stdout.removeListener("data", dataHandler);
|
||||
interpreter.stdout.pipe(res, {end: false});
|
||||
socket.removeListener("data", dataHandler);
|
||||
socket.pipe(res, {end: false});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var socket = net.createConnection({
|
||||
socket = net.createConnection({
|
||||
host: scgiConf.host,
|
||||
port: scgiConf.port,
|
||||
}, function () {
|
||||
|
|
Loading…
Reference in a new issue