From: Ji-hoon Lee Date: Tue, 8 Aug 2017 10:05:07 +0000 (+0900) Subject: Allow only a single write operation per one writable callback X-Git-Tag: accepted/tizen/3.0/common/20170810.115428~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3927c554f016f7db99d4c26ac8e7828f381e7db1;p=platform%2Fcore%2Fuifw%2Flibscl-core.git Allow only a single write operation per one writable callback Change-Id: I87b2bca02eb6832f84c1cc3a213d16c7f42c92eb --- diff --git a/src/legacy_support/websocket.cpp b/src/legacy_support/websocket.cpp index aa82219..507f3b8 100644 --- a/src/legacy_support/websocket.cpp +++ b/src/legacy_support/websocket.cpp @@ -127,7 +127,7 @@ static int callback_keyboard(struct lws *wsi, if (pss->valid) { pthread_mutex_lock(&g_ws_server_mutex); std::queue& messages = agent->get_send_message_queue(); - while (messages.size() > 0) { + if (messages.size() > 0) { ISE_MESSAGE &message = messages.front(); std::string str = CISEMessageSerializer::serialize(message); LOGD("SEND_WEBSOCKET_MESSAGE : %s", str.c_str()); @@ -139,9 +139,13 @@ static int callback_keyboard(struct lws *wsi, pthread_mutex_unlock(&g_ws_server_mutex); if (n < 0) { - lwsl_err("ERROR %d writing to di socket\n", n); + LOGE("ERROR %d writing to di socket\n", n); return -1; } + + if (messages.size() > 0) { + lws_callback_on_writable_all_protocol(g_ws_server_context, &protocols[PROTOCOL_KEYBOARD]); + } } else { LOGD("Rejecting data transmission since client is not valid"); }