From ed39db2d8d5133c5956245adb384b25cc65d0d8e Mon Sep 17 00:00:00 2001 From: Falk Werner Date: Sat, 13 Jun 2020 23:45:29 +0200 Subject: [PATCH] fix: minor fixes --- lib/webfuse/adapter/impl/client_protocol.c | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/webfuse/adapter/impl/client_protocol.c b/lib/webfuse/adapter/impl/client_protocol.c index 3eb1493..8f408d4 100644 --- a/lib/webfuse/adapter/impl/client_protocol.c +++ b/lib/webfuse/adapter/impl/client_protocol.c @@ -136,12 +136,13 @@ static int wf_impl_client_protocol_lws_callback( break; case LWS_CALLBACK_CLIENT_CONNECTION_ERROR: protocol->is_connected = false; + protocol->wsi = NULL; protocol->callback(protocol->user_data, WF_CLIENT_DISCONNECTED, NULL); break; case LWS_CALLBACK_CLIENT_CLOSED: protocol->is_connected = false; - protocol->callback(protocol->user_data, WF_CLIENT_DISCONNECTED, NULL); protocol->wsi = NULL; + protocol->callback(protocol->user_data, WF_CLIENT_DISCONNECTED, NULL); break; case LWS_CALLBACK_CLIENT_RECEIVE: wf_impl_client_protocol_process(protocol, in, len); @@ -154,19 +155,20 @@ static int wf_impl_client_protocol_lws_callback( { result = 1; } - else if (!wf_slist_empty(&protocol->messages)) - { - struct wf_slist_item * item = wf_slist_remove_first(&protocol->messages); - struct wf_message * message = wf_container_of(item, struct wf_message, item); - lws_write(wsi, (unsigned char*) message->data, message->length, LWS_WRITE_TEXT); - wf_message_dispose(message); - - if (!wf_slist_empty(&protocol->messages)) + else if (!wf_slist_empty(&protocol->messages)) { - lws_callback_on_writable(wsi); + struct wf_slist_item * item = wf_slist_remove_first(&protocol->messages); + struct wf_message * message = wf_container_of(item, struct wf_message, item); + lws_write(wsi, (unsigned char*) message->data, message->length, LWS_WRITE_TEXT); + wf_message_dispose(message); + + if (!wf_slist_empty(&protocol->messages)) + { + lws_callback_on_writable(wsi); + } } } - } + break; default: break; }