1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

service: make sure to sleep if nothing to do

https://github.com/warmcat/libwebsockets/issues/2524
This commit is contained in:
Paul Lee 2021-12-14 06:56:45 +00:00 committed by Andy Green
parent 7aaa87766d
commit 141ebf373c

View file

@ -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);