Browse Source

Fix list corruption in ACLK sync code and remove fatal (#11444)

* Make sure an element was found for removal

* Remove fatal if async send fails
Add newline
Stelios Fragkakis 3 years ago
parent
commit
1e415e4a04
1 changed files with 7 additions and 4 deletions
  1. 7 4
      database/sqlite/sqlite_aclk.c

+ 7 - 4
database/sqlite/sqlite_aclk.c

@@ -47,9 +47,10 @@ void aclk_del_worker_thread(struct aclk_database_worker_config *wc)
 
     uv_mutex_lock(&aclk_async_lock);
     struct aclk_database_worker_config **tmp = &aclk_thread_head;
-    while ((*tmp) != wc)
+    while (*tmp && (*tmp) != wc)
         tmp = &(*tmp)->next;
-    *tmp = wc->next;
+    if (*tmp)
+        *tmp = wc->next;
     uv_mutex_unlock(&aclk_async_lock);
     return;
 }
@@ -134,7 +135,9 @@ void aclk_database_enq_cmd(struct aclk_database_worker_config *wc, struct aclk_d
     uv_mutex_unlock(&wc->cmd_mutex);
 
     /* wake up event loop */
-    fatal_assert(0 == uv_async_send(&wc->async));
+    int rc = uv_async_send(&wc->async);
+    if (unlikely(rc))
+        debug(D_ACLK_SYNC, "Failed to wake up event loop");
 }
 
 struct aclk_database_cmd aclk_database_deq_cmd(struct aclk_database_worker_config* wc)
@@ -851,4 +854,4 @@ void aclk_data_rotated(RRDHOST *host)
     }
     uv_mutex_unlock(&aclk_async_lock);
     return;
-}
+}