[Libwebsockets] v1.7.1 high CPU load in LWSS_SHUTDOWN state
andrejs.hanins at ubnt.com
Wed Feb 24 14:19:35 CET 2016
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.
More information about the Libwebsockets