提交 b9494734 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Worker.js: add closed guard

上级 17e203bc
...@@ -58,6 +58,9 @@ class Worker extends EventEmitter ...@@ -58,6 +58,9 @@ class Worker extends EventEmitter
stdio : [ 'ignore', 'pipe', 'pipe', 'pipe' ] stdio : [ 'ignore', 'pipe', 'pipe', 'pipe' ]
}; };
// Closed flag.
this._closed = false;
// Create the mediasoup-worker child process. // Create the mediasoup-worker child process.
this._child = spawn(workerPath, spawnArgs, spawnOptions); this._child = spawn(workerPath, spawnArgs, spawnOptions);
...@@ -114,6 +117,11 @@ class Worker extends EventEmitter ...@@ -114,6 +117,11 @@ class Worker extends EventEmitter
{ {
logger.debug('close()'); logger.debug('close()');
if (this._closed)
return;
this._closed = true;
this.emit('@close'); this.emit('@close');
// Kill mediasoup-worker process. // Kill mediasoup-worker process.
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论