[Libwebsockets] v1.7.1 high CPU load in LWSS_SHUTDOWN state
andy at warmcat.com
Wed Feb 24 14:35:31 CET 2016
On 02/24/2016 09:19 PM, Andrejs Hanins wrote:
> It's me again about v1.7.1 regressions...
> This time I get high CPU load due to continuously repeating calls of lws_service_fd from external message loop because of pending POLLOUT. The WSI is in mode=LWSCM_WS_SERVING and state=LWSS_SHUTDOWN. It seems that if lws_callback_on_writable is called in this state then LWS_POLLOUT polling flag is added and it causes immediate trigger of the lws_service_fd which doesn't call lws_handle_POLLOUT_event due to state checks and falls down to handled label without doing anything. But as socket is still writable, lws_service_fd is called again and again, so causing high CPU load.
> The fix which works for me is ignore lws_callback_on_writable requests is WSI is in LWSS_SHUTDOWN state.
> Andy, you might have a better fix in mind.
Thanks I pushed a matching fix
The code already took care about defeating POLLOUT when entering
LWSS_SHUTDOWN but I didn't think about something coming afterwards and
setting POLLOUT again.
> BR, Andrey
> Libwebsockets mailing list
> Libwebsockets at libwebsockets.org
More information about the Libwebsockets