From f9e40b1d644f5293b66aeef03823210c5641c6ad Mon Sep 17 00:00:00 2001 From: Seonah Moon Date: Thu, 15 Apr 2021 15:27:53 +0900 Subject: [PATCH] Fix crash issues Change-Id: I04413f0cad969934f8cbaf3861cde409f6b00319 --- plugins/libwebsockets/libwebsockets-plugin.cpp | 3 +++ src/include/vine-queue.h | 1 + src/vine-data-path.cpp | 3 ++- tool/tool_run.cpp | 14 ++++++++------ 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/plugins/libwebsockets/libwebsockets-plugin.cpp b/plugins/libwebsockets/libwebsockets-plugin.cpp index 52894ef..99cacd7 100755 --- a/plugins/libwebsockets/libwebsockets-plugin.cpp +++ b/plugins/libwebsockets/libwebsockets-plugin.cpp @@ -736,6 +736,9 @@ static int websocket_read(vine_dp_plugin_h handle, unsigned char *buf, size_t le static void _request_write(websocket_s *ws) { + if (!ws->wsi) + return; + VINE_LOGI("Request write callback for %p", ws); lws_callback_on_writable(ws->wsi); } diff --git a/src/include/vine-queue.h b/src/include/vine-queue.h index 9fab778..681d357 100755 --- a/src/include/vine-queue.h +++ b/src/include/vine-queue.h @@ -59,6 +59,7 @@ public: T &front() { + std::lock_guard lock_guard(_q_mutex); return _queue.front(); } diff --git a/src/vine-data-path.cpp b/src/vine-data-path.cpp index 4a255cf..dff898a 100755 --- a/src/vine-data-path.cpp +++ b/src/vine-data-path.cpp @@ -142,12 +142,13 @@ void __vine_dp_poll_handler(int fd, int events, void *user_data) void __vine_dp_op_handler(int fd, int events, void *user_data) { uint64_t v; + + vine_event_loop_del_io_handler(fd); if (read(fd, &v, sizeof(v)) == -1) { VINE_LOGE("Read error(%d)", errno); return; } g_dp_plugin_fn.process_event(fd, events); - vine_event_loop_del_io_handler(fd); } static void __pollfd_cb(vine_data_path_pollfd_op_e op, int fd, int events) diff --git a/tool/tool_run.cpp b/tool/tool_run.cpp index f29eb97..633929d 100644 --- a/tool/tool_run.cpp +++ b/tool/tool_run.cpp @@ -355,17 +355,19 @@ static void deinit() static void _logger(int log_level, const char *log) { - if (log_file) { - fprintf(log_file, "%s\n", log); - return; - } - struct timespec ts; if(clock_gettime(CLOCK_REALTIME, &ts) == -1 ) return; - printf("[%ld.%03ld][T%5u] ", + char stamp[58] = {0, }; + snprintf(stamp, 57, "[%ld.%03ld][T%5u]", ts.tv_sec, ts.tv_nsec / 1000000, (unsigned int)syscall(__NR_gettid)); + + if (log_file) { + fprintf(log_file, "%s %s\n", stamp, log); + return; + } + printf("%s ", stamp); switch (log_level) { case VINE_LOG_DEBUG: printf("DEBUG: "); -- 2.7.4