MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / evs_unsub

Function evs_unsub

modules/freeswitch/fs_api.c:537–578  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

535}
536
537void evs_unsub(fs_evs *sock, const str *tag, const str_list *name)
538{
539 struct fs_event *event;
540 int ret = 0;
541
542 lock_start_write(sock->lists_lk);
543
544 for (; name; name = name->next) {
545 event = get_event(sock, &name->s);
546 if (!event) {
547 LM_DBG("not subscribed for %.*s\n", name->s.len, name->s.s);
548 continue;
549 }
550
551 if (del_event_subscription(event, tag) != 0) {
552 LM_DBG("%.*s is not subscribed to %.*s\n", tag->len, tag->s,
553 name->s.len, name->s.s);
554 continue;
555 }
556
557 if (event->refsum == 0) {
558 /* there is a pending sub action we must cancel! */
559 if (event->action == FS_EVENT_SUB)
560 event->action = FS_EVENT_NOP;
561 else
562 event->action = FS_EVENT_UNSUB;
563 }
564 }
565
566 lock_stop_write(sock->lists_lk);
567
568 /* always place it in the ESL "todo" list; we released the lock, so we
569 * cannot guarantee that the above esl_cmd's haven't been consumed by now
570 * worst case: we mark it as "todo" with no pending cmds, which is fine */
571 lock_start_write(sockets_esl_lock);
572 if (list_empty(&sock->esl_cmd_list))
573 list_add_tail(&sock->esl_cmd_list, fs_sockets_esl);
574 lock_stop_write(sockets_esl_lock);
575
576 if (ret != 0)
577 LM_ERR("oom! some events may have been skipped\n");
578}
579
580void evs_set_flags(fs_evs *sock, unsigned int flags)
581{

Callers 1

put_stats_evsFunction · 0.85

Calls 4

del_event_subscriptionFunction · 0.85
list_emptyFunction · 0.85
list_add_tailFunction · 0.85
get_eventFunction · 0.70

Tested by

no test coverage detected