Cleanup all singletons
The problem with starting Tango twice in one process basically boils down to us not deleting and nulling singleton objects. I find the following singletons:
> rg "\b_instance\b" src/include/
src/include/tango/server/utils.h
128:// protected and the _instance data member is static)
1176: TANGO_IMP static Util *_instance;
src/include/tango/server/eventsupplier.h
286: static NotifdEventSupplier *_instance;
393: static ZmqEventSupplier *_instance;
src/include/tango/server/dserverclass.h
524:// protected and the _instance data member is static)
545: TANGO_IMP static DServerClass *_instance;
src/include/tango/server/dserversignal.h
166: static std::unique_ptr<DServerSignal> _instance;
src/include/tango/client/ApiUtil.h
342: static ApiUtil *_instance;
We are already cleaning up the DServerSignal singleton in server_cleanup() which is called in server_cleanup(). And we already provide a function so that users can clean up the ApiUtil singleton.
For the other singletons (Util, NotifdEventSupplier/ZmqEventSupplier[1], DServerClass) I have added cleanup() static method and for all except Util I am calling the cleanup at (what I think is) an appropriate time during Util::shutdown_ds(). For Util it is up to the user to call Util::cleanup() themselves if they want to re-create the Util singleton.
TODO
-
Wait for !1501 (merged) and add some tests here to check that e.g. the event system is working etc.
-
Double check all static data is getting reset appropriately
-
Double check that the order things are being cleaned up in makes sense
-
Test this against the pytango unit tests
Seems to work for simple cases, but they cannot change the green_mode between runs. @yamatveyev Suggests this is acceptable for now.
-
Try out ASAN to see if I have fixed the problem in event_lockSave this for another time as we want to get this into release/10.3.0
-
Target 10.3.0 release branch
-
Get it working on WindowsSkip tests on Windows
[1] Interestingly, the EventConsumers are just regular members of the ApiUtil singleton. I don't know if we want to look at making EventSuppliers and EventConsumers to follow the same pattern.
Closes #1556 (closed).