Skip to content

Commit

Permalink
Close WebSockets explicitly
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Marr <git@stefan-marr.de>
  • Loading branch information
smarr committed Dec 20, 2017
1 parent 482342b commit 3f38adc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
12 changes: 11 additions & 1 deletion tools/kompos/src/vm-connection.ts
Expand Up @@ -119,7 +119,17 @@ export class VmConnection {
}

public disconnect() {
console.assert(this.isConnected());
if (this.socket) {
try {
this.socket.terminate();
} catch (_) { }
}

if (this.traceDataSocket) {
try {
this.traceDataSocket.terminate();
} catch (_) { }
}
}

public requestProgramInfo() {
Expand Down
14 changes: 5 additions & 9 deletions tools/kompos/tests/test-setup.ts
Expand Up @@ -155,17 +155,13 @@ export class TestConnection extends VmConnection {
}

public close(done: MochaDone) {
if (this.closed) {
done();
return;
if (!this.closed) {
this.closed = true;
this.disconnect();
this.somProc.kill();
}

this.somProc.on("exit", _code => {
this.closed = true;
// wait until process is shut down, to make sure all ports are closed
done();
});
this.somProc.kill();
done();
}
}

Expand Down

0 comments on commit 3f38adc

Please sign in to comment.