Fix crash issues 36/256936/4 accepted/tizen/unified/20210416.011800 submit/tizen/20210415.090745
authorSeonah Moon <seonah1.moon@samsung.com>
Thu, 15 Apr 2021 06:27:53 +0000 (15:27 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Thu, 15 Apr 2021 08:34:40 +0000 (17:34 +0900)
Change-Id: I04413f0cad969934f8cbaf3861cde409f6b00319

plugins/libwebsockets/libwebsockets-plugin.cpp
src/include/vine-queue.h
src/vine-data-path.cpp
tool/tool_run.cpp

index 52894ef..99cacd7 100755 (executable)
@@ -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);
 }
index 9fab778..681d357 100755 (executable)
@@ -59,6 +59,7 @@ public:
 
        T &front()
        {
+               std::lock_guard<std::mutex> lock_guard(_q_mutex);
                return _queue.front();
        }
 
index 4a255cf..dff898a 100755 (executable)
@@ -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)
index f29eb97..633929d 100644 (file)
@@ -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: ");