Browse Source

TT#106150 fix possible race condition while processing WS queue

Change-Id: I1137d828487e988b7afc3a0992312e4d8a0de876
pull/1163/head
Richard Fuchs 5 years ago
parent
commit
cd577a2710
1 changed files with 6 additions and 5 deletions
  1. +6
    -5
      daemon/websocket.c

+ 6
- 5
daemon/websocket.c View File

@ -164,20 +164,21 @@ static const char *websocket_echo_process(struct websocket_message *wm) {
static void websocket_message_push(struct websocket_conn *wc, websocket_message_func_t func) { static void websocket_message_push(struct websocket_conn *wc, websocket_message_func_t func) {
struct websocket_message *wm = wc->wm;
assert(wm != NULL);
ilog(LOG_DEBUG, "Adding HTTP/WS message to processing queue"); ilog(LOG_DEBUG, "Adding HTTP/WS message to processing queue");
mutex_lock(&wc->lock);
struct websocket_message *wm = wc->wm;
assert(wm != NULL);
wm->func = func; wm->func = func;
mutex_lock(&wc->lock);
g_queue_push_tail(&wc->messages, wm); g_queue_push_tail(&wc->messages, wm);
wc->jobs++; wc->jobs++;
g_thread_pool_push(websocket_threads, wc, NULL); g_thread_pool_push(websocket_threads, wc, NULL);
mutex_unlock(&wc->lock);
wc->wm = websocket_message_new(wc); wc->wm = websocket_message_new(wc);
mutex_unlock(&wc->lock);
} }


Loading…
Cancel
Save