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

libev: continue idle loop if forced service

https://libwebsockets.org/pipermail/libwebsockets/2020-January/008235.html
This commit is contained in:
Zevv 2020-01-22 19:15:04 +00:00 committed by Andy Green
parent 31c11451ef
commit 978f2a476a
2 changed files with 8 additions and 6 deletions

View file

@ -46,6 +46,7 @@ lws_ev_idle_cb(struct ev_loop *loop, struct ev_idle *handle, int revents)
struct lws_context_per_thread *pt = lws_container_of(handle,
struct lws_context_per_thread, ev.idle);
lws_usec_t us;
int reschedule = 0;
lws_service_do_ripe_rxflow(pt);
@ -54,7 +55,7 @@ lws_ev_idle_cb(struct ev_loop *loop, struct ev_idle *handle, int revents)
*/
if (!lws_service_adjust_timeout(pt->context, 1, pt->tid))
/* -1 timeout means just do forced service */
_lws_plat_service_forced_tsi(pt->context, pt->tid);
reschedule = _lws_plat_service_forced_tsi(pt->context, pt->tid);
/* account for hrtimer */
@ -67,7 +68,8 @@ lws_ev_idle_cb(struct ev_loop *loop, struct ev_idle *handle, int revents)
lws_pt_unlock(pt);
/* there is nobody who needs service forcing, shut down idle */
ev_idle_stop(loop, handle);
if (!reschedule)
ev_idle_stop(loop, handle);
}
static void

View file

@ -37,9 +37,9 @@ int
_lws_plat_service_forced_tsi(struct lws_context *context, int tsi)
{
struct lws_context_per_thread *pt = &context->pt[tsi];
int m, n;
int m, n, r;
lws_service_flag_pending(context, tsi);
r = lws_service_flag_pending(context, tsi);
/* any socket with events to service? */
for (n = 0; n < (int)pt->fds_count; n++) {
@ -59,7 +59,7 @@ _lws_plat_service_forced_tsi(struct lws_context *context, int tsi)
lws_service_do_ripe_rxflow(pt);
return 0;
return r;
}
#define LWS_POLL_WAIT_LIMIT 2000000000
@ -204,7 +204,7 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
return 0;
}
if (_lws_plat_service_forced_tsi(context, tsi))
if (_lws_plat_service_forced_tsi(context, tsi) < 0)
return -1;
return 0;