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 committed
Aug 19, 2021 at 13:48 UTC
1e415e4a04efa1e8317403d4d9aa7125b31a3e39
1 file changed
+7
-4
database/sqlite/sqlite_aclk.c
+7
-4
@@ -47,9 +47,10 @@ void aclk_del_worker_thread(struct aclk_database_worker_config *wc)
47
48
uv_mutex_lock(&aclk_async_lock);
49
struct aclk_database_worker_config **tmp = &aclk_thread_head;
50
- while ((*tmp) != wc)
50
+ while (*tmp && (*tmp) != wc)
51
tmp = &(*tmp)->next;
52
- *tmp = wc->next;
52
+ if (*tmp)
53
+ *tmp = wc->next;
54
uv_mutex_unlock(&aclk_async_lock);
55
return;
56
}
@@ -134,7 +135,9 @@ void aclk_database_enq_cmd(struct aclk_database_worker_config *wc, struct aclk_d
135
uv_mutex_unlock(&wc->cmd_mutex);
136
137
/* wake up event loop */
137
- fatal_assert(0 == uv_async_send(&wc->async));
138
+ int rc = uv_async_send(&wc->async);
139
+ if (unlikely(rc))
140
+ debug(D_ACLK_SYNC, "Failed to wake up event loop");
141
}
142
143
struct aclk_database_cmd aclk_database_deq_cmd(struct aclk_database_worker_config* wc)
@@ -851,4 +854,4 @@ void aclk_data_rotated(RRDHOST *host)
854
}
855
uv_mutex_unlock(&aclk_async_lock);
856
return;
854
-}
\ No newline at end of file
857
+}