diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2017-02-06 17:18:24 +0100 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2017-02-06 17:18:24 +0100 |
commit | 2b7d4554717a282d1e78a72dab6aa8e924b37b86 (patch) | |
tree | 198c7c9172a8db23f0ececf62a12d3888537fe08 /demo-json-rpc-server.c | |
parent | 0ec06857149d17ad0e86bb66f2fe9418bed13d8c (diff) | |
download | json-rpc-shell-2b7d4554717a282d1e78a72dab6aa8e924b37b86.tar.gz json-rpc-shell-2b7d4554717a282d1e78a72dab6aa8e924b37b86.tar.xz json-rpc-shell-2b7d4554717a282d1e78a72dab6aa8e924b37b86.zip |
Fix quitting
Diffstat (limited to 'demo-json-rpc-server.c')
-rw-r--r-- | demo-json-rpc-server.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/demo-json-rpc-server.c b/demo-json-rpc-server.c index 88f1adc..a528b60 100644 --- a/demo-json-rpc-server.c +++ b/demo-json-rpc-server.c @@ -1176,7 +1176,7 @@ server_context_init (struct server_context *self) str_map_init (&self->config); simple_config_load_defaults (&self->config, g_config_table); - ev_timer_init (&self->quit_timeout_watcher, on_quit_timeout, 0., 0.); + ev_timer_init (&self->quit_timeout_watcher, on_quit_timeout, 3., 0.); self->quit_timeout_watcher.data = self; } @@ -2260,13 +2260,15 @@ on_quit_timeout (EV_P_ ev_timer *watcher, int revents) static void initiate_quit (struct server_context *self) { + self->quitting = true; close_listeners (self); + + // Wait a little while for all clients to clean up, if necessary LIST_FOR_EACH (struct client, iter, self->clients) if (iter->vtable->shutdown) iter->vtable->shutdown (iter); - - ev_timer_set (&self->quit_timeout_watcher, 3., 0.); - self->quitting = true; + ev_timer_start (EV_DEFAULT_ &self->quit_timeout_watcher); + try_finish_quit (self); } static void |