address a file descriptor leak

This commit is contained in:
ansuz 2020-10-13 13:14:39 +05:30
parent a2c0d2165b
commit 6e57366b7f
1 changed files with 2 additions and 0 deletions

View File

@ -779,9 +779,11 @@ const messageBin = (env, chanName, msgBin, cb) => {
chan.writeStream.write(msgBin, function () {
chan.onError.splice(chan.onError.indexOf(complete), 1);
complete();
// It seems like this reintroduces a file descriptor leak
if (chan.onError.length) { return; }
if (chan.delayClose && chan.delayClose.clear) {
chan.delayClose.clear();
destroyStream(chan.writeStream, chanName);
delete env.channels[chanName];
}
});