You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Shutdown API server thread so it can thread::join()
The general presumption for Firecracker was that it would be exited
via an exit() call. This meant there was no way to signal threads
to exit their loops so they could be join()'d to release their
resources.
Not being able to exit the stack normally (if one wants to) misses
a sanity check that shutting down cleanly provides. The output of
Valgrind and other tools is also less useful.
Because the API Server thread is in a loop that does a blocking
wait on a socket, the only way to tell it to stop looping is via
information on that socket. This uses an internal HTTP GET signal
to request that shutdown. Rather than forget the thread handle
and the socket bind location, the main thread now sends the
shutdown request and then waits while the thread joins.
The request is for internal use only, however--because it is
supposed to happen after the Vmm has been cleaned up and its
contents destructed.
A different approach for signaling the thread for this purpose
could be used, e.g. to have the API server thread waiting on
multiple events (the socket or this internal signal). But since
this is only needed for clean shutdown, it is probably good enough.
A faster shutdown using exit() would be a better default--this
will likely only be used for debugging and Valgrind/sanitization.
0 commit comments