MT#55283 use typed GQueue for calls iterator

Change-Id: I67b2b9322ac0267932846d06e3f703cee2538e31
pull/1776/head
Richard Fuchs 1 year ago
parent a40557eb03
commit ce22afab57

@ -568,8 +568,8 @@ static void __call_iterator_remove(call_t *c) {
break; // we can remove now
}
if (c->iterator[i].link.data)
obj_put_o(c->iterator[i].link.data);
rtpe_call_iterators[i].first = g_list_remove_link(rtpe_call_iterators[i].first,
obj_put(c->iterator[i].link.data);
rtpe_call_iterators[i].first = t_list_remove_link(rtpe_call_iterators[i].first,
&c->iterator[i].link);
ZERO(c->iterator[i].link);
if (prev_call)
@ -4001,7 +4001,7 @@ restart:
break;
}
rtpe_call_iterators[i].first
= g_list_insert_before_link(rtpe_call_iterators[i].first,
= t_list_insert_before_link(rtpe_call_iterators[i].first,
rtpe_call_iterators[i].first, &c->iterator[i].link);
if (first_call)
mutex_unlock(&first_call->iterator[i].prev_lock);

@ -226,7 +226,7 @@ static void cli_handler_do(const cli_handler_t *handlers, str *instr,
static void destroy_own_foreign_calls(bool foreign_call, unsigned int uint_keyspace_db) {
struct call_monologue *ml = NULL;
GQueue call_list = G_QUEUE_INIT;
call_q calls = TYPED_GQUEUE_INIT;
ITERATE_CALL_LIST_START(CALL_ITERATOR_MAIN, c);
// match foreign_call flag
@ -243,13 +243,13 @@ static void destroy_own_foreign_calls(bool foreign_call, unsigned int uint_keysp
obj_get(c);
// save call reference
g_queue_push_tail(&call_list, c);
t_queue_push_tail(&calls, c);
next:;
ITERATE_CALL_LIST_NEXT_END(c);
// destroy calls
call_t *c = NULL;
while ((c = g_queue_pop_head(&call_list))) {
while ((c = t_queue_pop_head(&calls))) {
if (!c->ml_deleted) {
for (__auto_type i = c->monologues.head; i; i = i->next) {
ml = i->data;

@ -583,11 +583,11 @@ G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(monologues_q, monologues_q_clear)
TYPED_GHASHTABLE(tags_ht, str, struct call_monologue, str_hash, str_equal, NULL, NULL)
struct call_iterator_list {
GList *first;
call_list *first;
mutex_t lock; // protects .first and every entry's .data
};
struct call_iterator_entry {
GList link; // .data is protected by the list's main lock
call_list link; // .data is protected by the list's main lock
mutex_t next_lock; // held while the link is in use, protects link.data and link.next
mutex_t prev_lock; // held while the link is in use, protects link.prev
};
@ -597,7 +597,7 @@ struct call_iterator_entry {
int __which = (which); \
mutex_lock(&rtpe_call_iterators[__which].lock); \
\
GList *__l = rtpe_call_iterators[__which].first; \
__auto_type __l = rtpe_call_iterators[__which].first; \
bool __has_lock = true; \
call_t *next_ ## varname = NULL; \
while (__l) { \
@ -614,7 +614,7 @@ struct call_iterator_entry {
__has_lock = false
#define ITERATE_CALL_LIST_NEXT_END(varname) \
GList *__next = varname->iterator[__which].link.next; \
__auto_type __next = varname->iterator[__which].link.next; \
if (__next) { \
next_ ## varname = __next->data; \
obj_hold(next_ ## varname); \

@ -43,4 +43,6 @@ TYPED_GQUEUE(dtmf_event, struct dtmf_event)
struct codec_stats;
TYPED_GHASHTABLE_PROTO(codec_stats_ht, char, struct codec_stats)
TYPED_GQUEUE(call, call_t)
#endif

Loading…
Cancel
Save