static void detach_spies(struct ast_channel *chan) { struct ast_channel_spy *spy; if (!chan->spies) return; /* Marking the spies as done is sufficient. Chanspy or spy users will get the picture. */ AST_LIST_TRAVERSE(&chan->spies->list, spy, list) { ast_mutex_lock(&spy->lock); if (spy->status == CHANSPY_RUNNING) spy->status = CHANSPY_DONE; if (ast_test_flag(spy, CHANSPY_TRIGGER_MODE) != CHANSPY_TRIGGER_NONE) ast_cond_signal(&spy->trigger); ast_mutex_unlock(&spy->lock); } AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->spies->list, spy, list) ast_channel_spy_remove(chan, spy); AST_LIST_TRAVERSE_SAFE_END; }