1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

api: avoid segfault due to gone sessions

This commit is contained in:
Steffen Vogel 2018-11-02 14:56:07 +01:00
parent e3b522c39b
commit f004b4bf3f

View file

@ -68,7 +68,7 @@ void Api::stop()
for (Session *s : sessions)
s->shutdown();
for (int i = 0; i < 10 && sessions.size() > 0; i++) {
for (int i = 0; i < 2 && sessions.size() > 0; i++) {
logger->info("Waiting for {} sessions to terminate", sessions.size());
usleep(1 * 1e6);
}
@ -89,8 +89,14 @@ void Api::run()
/* Process pending actions */
Session *s = pending.pop();
if (s)
if (s) {
/* Check that the session is still alive */
auto it = std::find(sessions.begin(), sessions.end(), s);
if (it == sessions.end())
return;
s->runPendingActions();
}
}
void Api::worker()