Add delay before stopping server

Let some time to print any exception trace before killing it.
This commit is contained in:
Romain Vimont 2018-02-07 15:26:42 +01:00
parent cb1428223f
commit f39de46a39

View file

@ -685,6 +685,8 @@ screen_finally_destroy_renderer:
//SDL_DestroyRenderer(renderer); //SDL_DestroyRenderer(renderer);
screen_finally_destroy_window: screen_finally_destroy_window:
//SDL_DestroyWindow(window); //SDL_DestroyWindow(window);
// at least we hide it
SDL_HideWindow(window);
screen_finally_stop_and_join_controller: screen_finally_stop_and_join_controller:
controller_stop(&controller); controller_stop(&controller);
controller_join(&controller); controller_join(&controller);
@ -692,6 +694,14 @@ screen_finally_destroy_controller:
controller_destroy(&controller); controller_destroy(&controller);
screen_finally_stop_decoder: screen_finally_stop_decoder:
SDLNet_TCP_Close(device_socket); SDLNet_TCP_Close(device_socket);
// let the server some time to print any exception trace before killing it
struct timespec timespec = {
.tv_sec = 0,
.tv_nsec = 100000000, // 100ms
};
nanosleep(&timespec, NULL); // ignore error
// kill the server before decoder_join() to wake up the decoder // kill the server before decoder_join() to wake up the decoder
stop_server(server); stop_server(server);
decoder_join(&decoder); decoder_join(&decoder);