Skip to content

Commit 1e415e4

Browse files
authored
Fix list corruption in ACLK sync code and remove fatal (netdata#11444)
* Make sure an element was found for removal * Remove fatal if async send fails Add newline
1 parent 2a96d78 commit 1e415e4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

database/sqlite/sqlite_aclk.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ void aclk_del_worker_thread(struct aclk_database_worker_config *wc)
4747

4848
uv_mutex_lock(&aclk_async_lock);
4949
struct aclk_database_worker_config **tmp = &aclk_thread_head;
50-
while ((*tmp) != wc)
50+
while (*tmp && (*tmp) != wc)
5151
tmp = &(*tmp)->next;
52-
*tmp = wc->next;
52+
if (*tmp)
53+
*tmp = wc->next;
5354
uv_mutex_unlock(&aclk_async_lock);
5455
return;
5556
}
@@ -134,7 +135,9 @@ void aclk_database_enq_cmd(struct aclk_database_worker_config *wc, struct aclk_d
134135
uv_mutex_unlock(&wc->cmd_mutex);
135136

136137
/* 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");
138141
}
139142

140143
struct aclk_database_cmd aclk_database_deq_cmd(struct aclk_database_worker_config* wc)
@@ -851,4 +854,4 @@ void aclk_data_rotated(RRDHOST *host)
851854
}
852855
uv_mutex_unlock(&aclk_async_lock);
853856
return;
854-
}
857+
}

0 commit comments

Comments
 (0)