From 714ba5c9df85a730a6a7e28977e3a4783bddbb91 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Tue, 20 Feb 2018 12:07:10 +0800 Subject: [PATCH] async POLLOUT: pollfd change during end of POLLOUT handling change to explicit event reenable On ESP32 where the timer is on a different thread, otherwise threw occasional back-to-back writes. --- lib/service.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/service.c b/lib/service.c index 5961bbba..627b90d0 100644 --- a/lib/service.c +++ b/lib/service.c @@ -353,10 +353,17 @@ user_service: vwsi->handling_pollout = 0; /* cannot get leave_pollout_active set after the above */ - if (!eff && wsi->leave_pollout_active) - /* got set inbetween sampling eff and clearing - * handling_pollout, force POLLOUT on */ - lws_calllback_as_writeable(wsi); + if (!eff && wsi->leave_pollout_active) { + /* + * got set inbetween sampling eff and clearing + * handling_pollout, force POLLOUT on + */ + lwsl_debug("leave_pollout_active\n"); + if (lws_change_pollfd(wsi, 0, LWS_POLLOUT)) { + lwsl_info("failed at set pollfd\n"); + goto bail_die; + } + } vwsi->leave_pollout_active = 0; }