Skip to content

Commit

Permalink
polycubed: fix segfault on init (#114)
Browse files Browse the repository at this point in the history
* polycubed: fix segfault on init

When SIGINT was received at initialization time there was segfault because
the handler tried to delete the core and rest server that were not allocated
yet.  This commit adds a check to be sure that core and rest server are
allocated when the shutdown handler is invoked.

Fixes: 0df5d81 ("Initial commit")

Signed-off-by: Mauricio Vasquez B <mauriciovasquezbernal@gmail.com>

* Update polycubed.cpp
  • Loading branch information
mauriciovasquezbernal authored and frisso committed Apr 23, 2019
1 parent 1525d37 commit 9dc6142
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/polycubed/src/polycubed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ void shutdown() {
return;
// Service controllers depend on Rest Server. It is required to remove them
// before clearing the rest server in order to avoid segmentation faults.
core->clear_servicectrl_list();
restserver->shutdown();
logger->debug("rest was shutdown");
delete core;
if (core && restserver) {
core->clear_servicectrl_list();
restserver->shutdown();
logger->debug("rest server shutdown");
delete core;
delete restserver;
}
logger->info("polycubed is shutting down. Bye!");
done = true;
}
Expand Down

0 comments on commit 9dc6142

Please sign in to comment.