Process lws service after requesting to destroy a vhost 39/260139/1 accepted/tizen/unified/20210622.125832 submit/tizen/20210621.075049
authorSeonah Moon <seonah1.moon@samsung.com>
Mon, 21 Jun 2021 05:58:08 +0000 (14:58 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Mon, 21 Jun 2021 05:58:14 +0000 (14:58 +0900)
LWS closes a server socket next time around the event loop.

Change-Id: I9eeb1bad41dac93617ce13ef63474e1f0e8cc8cc

plugins/libwebsockets/libwebsockets-plugin.cpp

index 54cb6df..7669155 100755 (executable)
@@ -268,6 +268,13 @@ static void _del_websocket_op_request(websocket_op_s *op)
        free(op);
 }
 
+static void _process_pending_destroy(void)
+{
+       VINE_LOGD("Process pending destroy");
+       while (!lws_service_adjust_timeout(g_context, 1, 0))
+               lws_service_tsi(g_context, -1, 0);
+}
+
 static void _process_websocket_op_request(void)
 {
        RET_IF(op_queue.empty(), "operation queue is NULL");
@@ -291,6 +298,9 @@ static void _process_websocket_op_request(void)
        case WEBSOCKET_OP_WRITE:
                _request_write(op->ws);
                break;
+       case WEBSOCKET_OP_TERMINATE:
+               _process_pending_destroy();
+               break;
        default:
                break;
        }
@@ -997,6 +1007,11 @@ static int websocket_close(vine_dp_plugin_h handle)
                listen_vh_list.erase(ws->vh);
                lws_vhost_destroy(ws->vh);
                ws->vh = NULL;
+
+               _add_websocket_op_request(WEBSOCKET_OP_TERMINATE,
+                                       ws, 0, NULL, 0, NULL, 0, NULL);
+               _notify_websocket_op_request();
+
                return VINE_DATA_PATH_ERROR_NONE;
        }