Fix some shutdown issues in connection tracker code.
This commit is contained in:
parent
523c9c9ad2
commit
e56dc207d1
@ -2565,6 +2565,11 @@ void tf_ssb_destroy(tf_ssb_t* ssb)
|
||||
}
|
||||
}
|
||||
|
||||
bool tf_ssb_is_shutting_down(tf_ssb_t* ssb)
|
||||
{
|
||||
return ssb->shutting_down;
|
||||
}
|
||||
|
||||
void tf_ssb_run(tf_ssb_t* ssb)
|
||||
{
|
||||
uv_run(ssb->loop, UV_RUN_DEFAULT);
|
||||
|
@ -86,6 +86,10 @@ typedef struct _tf_ssb_connections_get_next_t
|
||||
static void _tf_ssb_connections_get_next_work(tf_ssb_t* ssb, void* user_data)
|
||||
{
|
||||
tf_ssb_connections_get_next_t* next = user_data;
|
||||
if (tf_ssb_is_shutting_down(ssb))
|
||||
{
|
||||
return;
|
||||
}
|
||||
next->ready = _tf_ssb_connections_get_next_connection(next->connections, next->host, sizeof(next->host), &next->port, next->key, sizeof(next->key));
|
||||
}
|
||||
|
||||
@ -159,6 +163,10 @@ typedef struct _tf_ssb_connections_update_t
|
||||
static void _tf_ssb_connections_update_work(tf_ssb_t* ssb, void* user_data)
|
||||
{
|
||||
tf_ssb_connections_update_t* update = user_data;
|
||||
if (tf_ssb_is_shutting_down(ssb))
|
||||
{
|
||||
return;
|
||||
}
|
||||
sqlite3_stmt* statement;
|
||||
sqlite3* db = tf_ssb_acquire_db_writer(ssb);
|
||||
if (update->attempted)
|
||||
|
@ -144,6 +144,13 @@ tf_ssb_t* tf_ssb_create(uv_loop_t* loop, JSContext* context, const char* db_path
|
||||
*/
|
||||
void tf_ssb_destroy(tf_ssb_t* ssb);
|
||||
|
||||
/**
|
||||
** Checking if the SSB instance is in the process of shutting down.
|
||||
** @param ssb The SSB instance.
|
||||
** @return true If the SSB instance is shutting down.
|
||||
*/
|
||||
bool tf_ssb_is_shutting_down(tf_ssb_t* ssb);
|
||||
|
||||
/**
|
||||
** Start optional periodic work.
|
||||
** @param ssb The SSB instance.
|
||||
|
Loading…
Reference in New Issue
Block a user