diff options
author | Oliver Smith <osmith@sysmocom.de> | 2021-12-21 19:17:51 +0100 |
---|---|---|
committer | neels <nhofmeyr@sysmocom.de> | 2021-12-28 12:14:12 +0000 |
commit | d841bec8d26615df776fc6573157c9532f226aff (patch) | |
tree | 4c7f598196edea61a65354f36762f527a34e9ba0 | |
parent | 29814a5374fe6f7bd79a9939c12cf3a098f59b59 (diff) |
select_main: don't poll forever during shutdown
Do not poll without timeout during shutdown if no timers are pending.
Change-Id: I81c64a7ae440304522c2179c212023a566ddced8
-rw-r--r-- | src/select.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/select.c b/src/select.c index b48d13e7..ddff1329 100644 --- a/src/select.c +++ b/src/select.c @@ -372,14 +372,20 @@ static int _osmo_select_main(int polling) { unsigned int n_poll; int rc; + int timeout = 0; /* prepare read and write fdsets */ n_poll = poll_fill_fds(); - if (!polling) + if (!polling) { osmo_timers_prepare(); + timeout = osmo_timers_nearest_ms(); + + if (_osmo_select_shutdown_requested && timeout == -1) + timeout = 0; + } - rc = poll(g_poll.poll, n_poll, polling ? 0 : osmo_timers_nearest_ms()); + rc = poll(g_poll.poll, n_poll, timeout); if (rc < 0) return 0; |