FS-10167: Fixed sessions to cleanup external from their own state processing thread to avoid deadlocking on thread join during cleanup.
This commit is contained in:
parent
dd6031544a
commit
dbd2ef2d8b
|
@ -505,8 +505,7 @@ ks_status_t blade_session_state_on_destroy(blade_session_t *bs)
|
||||||
|
|
||||||
ks_log(KS_LOG_DEBUG, "Session (%s) state destroy\n", bs->id);
|
ks_log(KS_LOG_DEBUG, "Session (%s) state destroy\n", bs->id);
|
||||||
|
|
||||||
blade_handle_sessions_remove(bs);
|
blade_session_state_set(bs, BLADE_SESSION_STATE_CLEANUP);
|
||||||
blade_session_destroy(&bs);
|
|
||||||
|
|
||||||
// @todo ignoring returns for now, see what makes sense later
|
// @todo ignoring returns for now, see what makes sense later
|
||||||
return KS_STATUS_SUCCESS;
|
return KS_STATUS_SUCCESS;
|
||||||
|
|
|
@ -889,6 +889,7 @@ void *blade_handle_worker_thread(ks_thread_t *thread, void *data)
|
||||||
{
|
{
|
||||||
blade_handle_t *bh = NULL;
|
blade_handle_t *bh = NULL;
|
||||||
blade_connection_t *bc = NULL;
|
blade_connection_t *bc = NULL;
|
||||||
|
blade_session_t *bs = NULL;
|
||||||
ks_hash_iterator_t *it = NULL;
|
ks_hash_iterator_t *it = NULL;
|
||||||
ks_q_t *cleanup = NULL;
|
ks_q_t *cleanup = NULL;
|
||||||
|
|
||||||
|
@ -917,6 +918,22 @@ void *blade_handle_worker_thread(ks_thread_t *thread, void *data)
|
||||||
blade_connection_destroy(&bc);
|
blade_connection_destroy(&bc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ks_hash_write_lock(bh->sessions);
|
||||||
|
for (it = ks_hash_first(bh->sessions, KS_UNLOCKED); it; it = ks_hash_next(&it)) {
|
||||||
|
void *key = NULL;
|
||||||
|
blade_session_t *value = NULL;
|
||||||
|
|
||||||
|
ks_hash_this(it, (const void **)&key, NULL, (void **)&value);
|
||||||
|
|
||||||
|
if (blade_session_state_get(value) == BLADE_SESSION_STATE_CLEANUP) ks_q_push(cleanup, value);
|
||||||
|
}
|
||||||
|
ks_hash_write_unlock(bh->sessions);
|
||||||
|
|
||||||
|
while (ks_q_trypop(cleanup, (void **)&bs) == KS_STATUS_SUCCESS) {
|
||||||
|
blade_handle_sessions_remove(bs);
|
||||||
|
blade_session_destroy(&bs);
|
||||||
|
}
|
||||||
|
|
||||||
ks_sleep_ms(500);
|
ks_sleep_ms(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,7 @@ typedef enum {
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
BLADE_SESSION_STATE_NONE,
|
BLADE_SESSION_STATE_NONE,
|
||||||
|
BLADE_SESSION_STATE_CLEANUP,
|
||||||
BLADE_SESSION_STATE_DESTROY,
|
BLADE_SESSION_STATE_DESTROY,
|
||||||
BLADE_SESSION_STATE_HANGUP,
|
BLADE_SESSION_STATE_HANGUP,
|
||||||
BLADE_SESSION_STATE_CONNECT,
|
BLADE_SESSION_STATE_CONNECT,
|
||||||
|
|
Loading…
Reference in New Issue