From: cheoleun moon Date: Thu, 21 Oct 2021 10:25:53 +0000 (+0900) Subject: Iterate op_queue to process the matching fd X-Git-Tag: submit/tizen_6.5/20211109.070706~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c4565821dc11e9b2d0ca974e9013eb63a96fc7df;p=platform%2Fcore%2Fapi%2Fvine.git Iterate op_queue to process the matching fd Change-Id: I502031323dd98cc86e5a22750571f2d246903658 --- diff --git a/plugins/libwebsockets/libwebsockets-plugin.cpp b/plugins/libwebsockets/libwebsockets-plugin.cpp index 748a117..feb98d4 100755 --- a/plugins/libwebsockets/libwebsockets-plugin.cpp +++ b/plugins/libwebsockets/libwebsockets-plugin.cpp @@ -347,15 +347,12 @@ static void _deinit(void) VINE_LOGI("-"); } -static void _process_websocket_op_request(int fd) +static void _do_process_op(websocket_op_s *op) { - RET_IF(op_queue.empty(), "operation queue is NULL"); - - websocket_op_s *op = op_queue.front(); - RET_IF(op == NULL, "op is NULL"); - RET_IF(op->fd != fd, "Not matched event. op->fd[%d] fd[%d]", op->fd, fd); + if (op == NULL) + return; - op_queue.pop(); + VINE_LOGD("op[%p] op->ws[%p] op->fd[%d] op->code[%d]", op, op->ws, op->fd, op->code); if (!op->ws && op->code != WEBSOCKET_OP_DEINIT) { _del_websocket_op_request(op); @@ -389,7 +386,17 @@ static void _process_websocket_op_request(int fd) _del_websocket_op_request(op); } -static void do_func(websocket_op_s *op) +static void _process_websocket_op_request(int fd) +{ + RET_IF(op_queue.empty(), "operation queue is NULL"); + + VINE_LOGD("fd[%d]", fd); + op_queue.do_remove_if([&](websocket_op_s *op) { + return op->fd == fd; + }, _do_process_op); +} + +static void _do_flush_op(websocket_op_s *op) { if (op == NULL) return; @@ -430,7 +437,7 @@ static void _flush_op_queue(websocket_s *ws) while (count-- > 0) { op_queue.do_remove_if([&](websocket_op_s *op) { return (ws == NULL || (op && op->ws == ws)); - }, do_func); + }, _do_flush_op); } } @@ -560,11 +567,11 @@ static int _websocket_protocol_cb(struct lws *wsi, break; case LWS_CALLBACK_LOCK_POLL: - pthread_mutex_lock(&g_lws_mutex); + n = pthread_mutex_lock(&g_lws_mutex); break; case LWS_CALLBACK_UNLOCK_POLL: - pthread_mutex_unlock(&g_lws_mutex); + n = pthread_mutex_unlock(&g_lws_mutex); break; /* --- protocol lifecycle callbacks --- */ diff --git a/src/vine-dp.cpp b/src/vine-dp.cpp index e2e04d1..3dc9a17 100755 --- a/src/vine-dp.cpp +++ b/src/vine-dp.cpp @@ -1588,6 +1588,7 @@ int _vine_dp_create(vine_session_h session, vine_dp_type_e type, vine_dp_h *dp) *dp = new DPPubSub((void *)eq); } + VINE_LOGD("dp[%p]", *dp); return VINE_ERROR_NONE; } @@ -1800,6 +1801,7 @@ int _vine_dp_open(vine_dp_h dp, vine_dp_opened_cb callback, void *user_data) RET_VAL_IF(dp == NULL, VINE_ERROR_INVALID_PARAMETER, "dp is null."); RET_VAL_IF(callback == NULL, VINE_ERROR_INVALID_PARAMETER, "callback is null."); + VINE_LOGD("dp[%p]", dp); DataPath *_dp = static_cast(dp); return _dp->open(callback, user_data); } @@ -1808,6 +1810,7 @@ int _vine_dp_close(vine_dp_h dp) { RET_VAL_IF(dp == NULL, VINE_ERROR_INVALID_PARAMETER, "dp is null."); + VINE_LOGD("dp[%p]", dp); DataPath *_dp = static_cast(dp); return _dp->close(); } @@ -1817,6 +1820,7 @@ int _vine_dp_send(vine_dp_h dp, unsigned char *buf, size_t len) RET_VAL_IF(dp == NULL, VINE_ERROR_INVALID_PARAMETER, "dp is null."); RET_VAL_IF(buf == NULL, VINE_ERROR_INVALID_PARAMETER, "buf is null."); + VINE_LOGD("dp[%p]", dp); DataPath *_dp = static_cast(dp); return _dp->send(buf, len); } @@ -1827,6 +1831,7 @@ int _vine_dp_recv(vine_dp_h dp, unsigned char *buf, size_t buf_len, size_t *read RET_VAL_IF(buf == NULL, VINE_ERROR_INVALID_PARAMETER, "buf is null."); RET_VAL_IF(read_len == NULL, VINE_ERROR_INVALID_PARAMETER, "read_len is null."); + VINE_LOGD("dp[%p]", dp); DataPath *_dp = static_cast(dp); return _dp->recv(buf, buf_len, read_len); }