diff options
author | Paul Lee <liberize@gmail.com> | 2021-12-14 06:56:45 +0000 |
---|---|---|
committer | Andy Green <andy@warmcat.com> | 2021-12-14 08:10:48 +0000 |
commit | 141ebf373ca0fed7b41eb960cdbd7ab1f29490dc (patch) | |
tree | bbe2391273950547374df0a219a0825551eca08d | |
parent | 7aaa87766dbce818a96f97fc780a3886fa23ea13 (diff) | |
download | libwebsockets-141ebf373ca0fed7b41eb960cdbd7ab1f29490dc.tar.gz |
service: make sure to sleep if nothing to do
https://github.com/warmcat/libwebsockets/issues/2524
-rw-r--r-- | lib/core-net/service.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/core-net/service.c b/lib/core-net/service.c index c7b15f32..02e4c05e 100644 --- a/lib/core-net/service.c +++ b/lib/core-net/service.c @@ -322,7 +322,11 @@ lws_service_adjust_timeout(struct lws_context *context, int timeout_ms, int tsi) u = __lws_sul_service_ripe(pt->pt_sul_owner, LWS_COUNT_PT_SUL_OWNERS, lws_now_usecs()); - if (u < (lws_usec_t)timeout_ms * (lws_usec_t)1000) + /* + * We will come back with 0 if nothing to do at the moment, or + * the number of us until something to do + */ + if (u && u < (lws_usec_t)timeout_ms * (lws_usec_t)1000) timeout_ms = (int)(u / 1000); lws_pt_unlock(pt); |