Interrupt and close sockets on server stop
The sockets were never interrupted or closed by the client since recent
changes to run the server from a dedicated thread (see commit
0426708544
).
As a side effect, the server could never terminate properly (it was
waiting on socket blocking calls), so it was always killed by the client
after the WATCHDOG_DELAY.
Interrupt the sockets on stop to give the servera chance to terminate
property, then close them.
This commit is contained in:
parent
cabcbc2b15
commit
ddb9396743
1 changed files with 11 additions and 0 deletions
|
@ -763,6 +763,17 @@ run_server(void *data) {
|
||||||
}
|
}
|
||||||
sc_mutex_unlock(&server->mutex);
|
sc_mutex_unlock(&server->mutex);
|
||||||
|
|
||||||
|
// Interrupt sockets to wake up socket blocking calls on the server
|
||||||
|
assert(server->video_socket != SC_SOCKET_NONE);
|
||||||
|
net_interrupt(server->video_socket);
|
||||||
|
net_close(server->video_socket);
|
||||||
|
|
||||||
|
if (server->control_socket != SC_SOCKET_NONE) {
|
||||||
|
// There is no control_socket if --no-control is set
|
||||||
|
net_interrupt(server->control_socket);
|
||||||
|
net_close(server->control_socket);
|
||||||
|
}
|
||||||
|
|
||||||
// Give some delay for the server to terminate properly
|
// Give some delay for the server to terminate properly
|
||||||
#define WATCHDOG_DELAY SC_TICK_FROM_SEC(1)
|
#define WATCHDOG_DELAY SC_TICK_FROM_SEC(1)
|
||||||
sc_tick deadline = sc_tick_now() + WATCHDOG_DELAY;
|
sc_tick deadline = sc_tick_now() + WATCHDOG_DELAY;
|
||||||
|
|
Loading…
Reference in a new issue