Index: main/manager.c =================================================================== --- main/manager.c (revision 125438) +++ main/manager.c (working copy) @@ -1522,14 +1522,18 @@ if (s->waiting_thread == pthread_self()) { struct eventqent *eqe; astman_send_response(s, m, "Success", "Waiting for Event completed."); + AST_LIST_LOCK(&all_events); while ( (eqe = NEW_EVENT(s)) ) { ref_event(eqe); + AST_LIST_UNLOCK(&all_events); if (((s->readperm & eqe->category) == eqe->category) && ((s->send_events & eqe->category) == eqe->category)) { astman_append(s, "%s", eqe->eventdata); } + AST_LIST_LOCK(&all_events); s->last_ev = unref_event(s->last_ev); } + AST_LIST_UNLOCK(&all_events); astman_append(s, "Event: WaitEventComplete\r\n" "%s" @@ -2373,16 +2377,20 @@ if (s->f != NULL) { struct eventqent *eqe; + AST_LIST_LOCK(&all_events); while ( (eqe = NEW_EVENT(s)) ) { ref_event(eqe); + AST_LIST_UNLOCK(&all_events); if (!ret && s->authenticated && (s->readperm & eqe->category) == eqe->category && (s->send_events & eqe->category) == eqe->category) { if (send_string(s, eqe->eventdata) < 0) ret = -1; /* don't send more */ } + AST_LIST_LOCK(&all_events); s->last_ev = unref_event(s->last_ev); } + AST_LIST_UNLOCK(&all_events); } ast_mutex_unlock(&s->__lock); return ret;