Prevented "write after end" SVR.JS crashes
This commit is contained in:
parent
841aff67ed
commit
f0977c9319
1 changed files with 7 additions and 3 deletions
10
index.js
10
index.js
|
@ -166,7 +166,11 @@ function createFastCGIHandler(options) {
|
||||||
var processedPacket = parseFastCGIPacket(packet);
|
var processedPacket = parseFastCGIPacket(packet);
|
||||||
if (processedPacket.requestID != requestID) return; //Drop the packet
|
if (processedPacket.requestID != requestID) return; //Drop the packet
|
||||||
if (processedPacket.type == STDOUT) {
|
if (processedPacket.type == STDOUT) {
|
||||||
if(processedPacket.content.length > 0) emulatedStdout.push(processedPacket.content);
|
try {
|
||||||
|
if(processedPacket.content.length > 0) emulatedStdout.push(processedPacket.content);
|
||||||
|
} catch (err) {
|
||||||
|
//STDOUT will be lost instead of crashing the server
|
||||||
|
}
|
||||||
} else if (processedPacket.type == STDERR) {
|
} else if (processedPacket.type == STDERR) {
|
||||||
try {
|
try {
|
||||||
if(processedPacket.content.length > 0) emulatedStderr.push(processedPacket.content);
|
if(processedPacket.content.length > 0) emulatedStderr.push(processedPacket.content);
|
||||||
|
@ -189,7 +193,7 @@ function createFastCGIHandler(options) {
|
||||||
err = new Error("Multiplexed connections not supported by the FastCGI application");
|
err = new Error("Multiplexed connections not supported by the FastCGI application");
|
||||||
}
|
}
|
||||||
emulatedStdout.push(null);
|
emulatedStdout.push(null);
|
||||||
if (emulatedStdout._readableState && emulatedStdout._readableState.length > 0 && emulatedStdout._readableState.flowing !== null) {
|
if (emulatedStdout._readableState && emulatedStdout._readableState.length > 0 && emulatedStdout._readableState.flowing !== null && !emulatedStdout.endEmitted) {
|
||||||
emulatedStdout.on("end", function() {
|
emulatedStdout.on("end", function() {
|
||||||
emulatedStderr.push(null);
|
emulatedStderr.push(null);
|
||||||
eventEmitter.emit("error", err);
|
eventEmitter.emit("error", err);
|
||||||
|
@ -200,7 +204,7 @@ function createFastCGIHandler(options) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emulatedStdout.push(null);
|
emulatedStdout.push(null);
|
||||||
if (emulatedStdout._readableState && emulatedStdout._readableState.length > 0 && emulatedStdout._readableState.flowing !== null) {
|
if (emulatedStdout._readableState && emulatedStdout._readableState.length > 0 && emulatedStdout._readableState.flowing !== null && !emulatedStdout.endEmitted) {
|
||||||
emulatedStdout.on("end", function() {
|
emulatedStdout.on("end", function() {
|
||||||
emulatedStderr.push(null);
|
emulatedStderr.push(null);
|
||||||
eventEmitter.emit("exit", appStatus, null);
|
eventEmitter.emit("exit", appStatus, null);
|
||||||
|
|
Loading…
Reference in a new issue