From 899b618a01614a35db77d99f571f0c84cca6c7a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20B=C3=BChler?= <david.buhler@cea.fr> Date: Thu, 21 May 2020 12:25:27 +0200 Subject: [PATCH] [ivette] Server: fixes the handling of signals. Always sends signal.on for all signals when restarting the Frama-C server. This requires to set [listen] to false for each signal on shutdown (the on signal is never send as long as [listen] is true). --- ivette/src/frama-c/server.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ivette/src/frama-c/server.ts b/ivette/src/frama-c/server.ts index 4220a8918ae..357becad041 100644 --- a/ivette/src/frama-c/server.ts +++ b/ivette/src/frama-c/server.ts @@ -618,6 +618,7 @@ class Signal { this.listen = false; this.sigon = this.sigon.bind(this); this.sigoff = _.debounce(this.sigoff.bind(this), 1000); + this.unplug = this.unplug.bind(this); } on(callback: any) { @@ -659,11 +660,15 @@ class Signal { } } } + + unplug() { + this.listen = false; + } } // --- Memo -const signals: any[] = []; +const signals: { [id: string]: Signal } = {}; function _signal(id: any) { let s = signals[id]; if (!s) { @@ -714,11 +719,16 @@ export function useSignal(id: string, callback: any) { // --- Server Synchro Dome.on(READY, () => { - _.forEach(signals, (s) => s.sigon()); + _.forEach(signals, (signal: Signal) => { + signal.sigon(); + }); }); Dome.on(SHUTDOWN, () => { - _.forEach(signals, (s) => s.sigoff.cancel()); + _.forEach(signals, (signal: Signal) => { + signal.unplug(); + // TODO: signal.sigoff.cancel(); + }); }); // -------------------------------------------------------------------------- -- GitLab