<p>Kevin Harwell <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11464">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Kevin Harwell: Looks good to me, approved; Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">MWI: Update modules that subscribe to MWI to use new API calls<br><br>The MWI core recently got some new API calls that make tracking MWI state<br>lifetime more reliable. This patch updates those modules that subscribe to<br>specific MWI topics to use the new API. Specifically, these modules now<br>subscribe to both MWI topics and MWI state.<br><br>ASTERISK-28442<br><br>Change-Id: I32bef880b647246823dbccdf44a98d384fcabfbd<br>---<br>M channels/chan_dahdi.c<br>M channels/chan_dahdi.h<br>M channels/chan_iax2.c<br>M channels/chan_mgcp.c<br>M channels/chan_sip.c<br>M channels/chan_skinny.c<br>M channels/sig_pri.c<br>M channels/sig_pri.h<br>M channels/sip/include/sip.h<br>M res/res_pjsip_mwi.c<br>10 files changed, 52 insertions(+), 96 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c</span><br><span>index 434bd16..a721d7b 100644</span><br><span>--- a/channels/chan_dahdi.c</span><br><span>+++ b/channels/chan_dahdi.c</span><br><span>@@ -5540,7 +5540,7 @@</span><br><span>              ao2_cleanup(p->smdi_iface);</span><br><span>       }</span><br><span>    if (p->mwi_event_sub) {</span><br><span style="color: hsl(0, 100%, 40%);">-              p->mwi_event_sub = stasis_unsubscribe(p->mwi_event_sub);</span><br><span style="color: hsl(120, 100%, 40%);">+                p->mwi_event_sub = ast_mwi_unsubscribe(p->mwi_event_sub);</span><br><span>      }</span><br><span>    if (p->vars) {</span><br><span>            ast_variables_destroy(p->vars);</span><br><span>@@ -12607,18 +12607,11 @@</span><br><span>               tmp->cid_subaddr[0] = '\0';</span><br><span>               ast_copy_string(tmp->mailbox, conf->chan.mailbox, sizeof(tmp->mailbox));</span><br><span>            if (channel != CHAN_PSEUDO && !ast_strlen_zero(tmp->mailbox)) {</span><br><span style="color: hsl(0, 100%, 40%);">-                      struct stasis_topic *mailbox_specific_topic;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-                    mailbox_specific_topic = ast_mwi_topic(tmp->mailbox);</span><br><span style="color: hsl(0, 100%, 40%);">-                        if (mailbox_specific_topic) {</span><br><span style="color: hsl(0, 100%, 40%);">-                           /* This module does not handle MWI in an event-based manner.  However, it</span><br><span style="color: hsl(0, 100%, 40%);">-                                * subscribes to MWI for each mailbox that is configured so that the core</span><br><span style="color: hsl(0, 100%, 40%);">-                                * knows that we care about it.  Then, chan_dahdi will get the MWI from the</span><br><span style="color: hsl(0, 100%, 40%);">-                              * event cache instead of checking the mailbox directly. */</span><br><span style="color: hsl(0, 100%, 40%);">-                             tmp->mwi_event_sub = stasis_subscribe_pool(mailbox_specific_topic, stasis_subscription_cb_noop, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-                               stasis_subscription_accept_message_type(tmp->mwi_event_sub, ast_mwi_state_type());</span><br><span style="color: hsl(0, 100%, 40%);">-                           stasis_subscription_set_filter(tmp->mwi_event_sub, STASIS_SUBSCRIPTION_FILTER_SELECTIVE);</span><br><span style="color: hsl(0, 100%, 40%);">-                    }</span><br><span style="color: hsl(120, 100%, 40%);">+                     /* This module does not handle MWI in an event-based manner.  However, it</span><br><span style="color: hsl(120, 100%, 40%);">+                      * subscribes to MWI for each mailbox that is configured so that the core</span><br><span style="color: hsl(120, 100%, 40%);">+                      * knows that we care about it.  Then, chan_dahdi will get the MWI from the</span><br><span style="color: hsl(120, 100%, 40%);">+                    * event cache instead of checking the mailbox directly. */</span><br><span style="color: hsl(120, 100%, 40%);">+                   tmp->mwi_event_sub = ast_mwi_subscribe_pool(tmp->mailbox, stasis_subscription_cb_noop, NULL);</span><br><span>          }</span><br><span> #ifdef HAVE_DAHDI_LINEREVERSE_VMWI</span><br><span>              tmp->mwisend_setting = conf->chan.mwisend_setting;</span><br><span>diff --git a/channels/chan_dahdi.h b/channels/chan_dahdi.h</span><br><span>index 212a0bf..d84be51 100644</span><br><span>--- a/channels/chan_dahdi.h</span><br><span>+++ b/channels/chan_dahdi.h</span><br><span>@@ -653,7 +653,7 @@</span><br><span>       */</span><br><span>  char mailbox[AST_MAX_MAILBOX_UNIQUEID];</span><br><span>      /*! \brief Opaque event subscription parameters for message waiting indication support. */</span><br><span style="color: hsl(0, 100%, 40%);">-      struct stasis_subscription *mwi_event_sub;</span><br><span style="color: hsl(120, 100%, 40%);">+    struct ast_mwi_subscriber *mwi_event_sub;</span><br><span>    /*! \brief Delayed dialing for E911.  Overlap digits for ISDN. */</span><br><span>    char dialdest[256];</span><br><span> #ifdef HAVE_DAHDI_LINEREVERSE_VMWI</span><br><span>diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c</span><br><span>index a7b2f26..30f9496 100644</span><br><span>--- a/channels/chan_iax2.c</span><br><span>+++ b/channels/chan_iax2.c</span><br><span>@@ -582,7 +582,7 @@</span><br><span>         int smoothing;                                  /*!< Sample over how many units to determine historic ms */</span><br><span>       uint16_t maxcallno;                             /*!< Max call number limit for this peer.  Set on registration */</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-        struct stasis_subscription *mwi_event_sub;      /*!< This subscription lets pollmailboxes know which mailboxes need to be polled */</span><br><span style="color: hsl(120, 100%, 40%);">+        struct ast_mwi_subscriber *mwi_event_sub;       /*!< This subscription lets pollmailboxes know which mailboxes need to be polled */</span><br><span> </span><br><span>   struct ast_acl_list *acl;</span><br><span>    enum calltoken_peer_enum calltoken_required;    /*!< Is calltoken validation required or not, can be YES, NO, or AUTO */</span><br><span>@@ -12764,7 +12764,9 @@</span><br><span>        if (peer->dnsmgr)</span><br><span>                 ast_dnsmgr_release(peer->dnsmgr);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-        peer->mwi_event_sub = stasis_unsubscribe(peer->mwi_event_sub);</span><br><span style="color: hsl(120, 100%, 40%);">+  if (peer->mwi_event_sub) {</span><br><span style="color: hsl(120, 100%, 40%);">+         peer->mwi_event_sub = ast_mwi_unsubscribe(peer->mwi_event_sub);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> </span><br><span>        ast_string_field_free_memory(peer);</span><br><span> </span><br><span>@@ -13069,17 +13071,10 @@</span><br><span>  }</span><br><span> </span><br><span>        if (!ast_strlen_zero(peer->mailbox) && !peer->mwi_event_sub) {</span><br><span style="color: hsl(0, 100%, 40%);">-            struct stasis_topic *mailbox_specific_topic;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-            mailbox_specific_topic = ast_mwi_topic(peer->mailbox);</span><br><span style="color: hsl(0, 100%, 40%);">-               if (mailbox_specific_topic) {</span><br><span style="color: hsl(0, 100%, 40%);">-                   /* The MWI subscriptions exist just so the core knows we care about those</span><br><span style="color: hsl(0, 100%, 40%);">-                        * mailboxes.  However, we just grab the events out of the cache when it</span><br><span style="color: hsl(0, 100%, 40%);">-                         * is time to send MWI, since it is only sent with a REGACK. */</span><br><span style="color: hsl(0, 100%, 40%);">-                 peer->mwi_event_sub = stasis_subscribe_pool(mailbox_specific_topic, stasis_subscription_cb_noop, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-                      stasis_subscription_accept_message_type(peer->mwi_event_sub, ast_mwi_state_type());</span><br><span style="color: hsl(0, 100%, 40%);">-                  stasis_subscription_set_filter(peer->mwi_event_sub, STASIS_SUBSCRIPTION_FILTER_SELECTIVE);</span><br><span style="color: hsl(0, 100%, 40%);">-           }</span><br><span style="color: hsl(120, 100%, 40%);">+             /* The MWI subscriptions exist just so the core knows we care about those</span><br><span style="color: hsl(120, 100%, 40%);">+              * mailboxes.  However, we just grab the events out of the cache when it</span><br><span style="color: hsl(120, 100%, 40%);">+               * is time to send MWI, since it is only sent with a REGACK. */</span><br><span style="color: hsl(120, 100%, 40%);">+               peer->mwi_event_sub = ast_mwi_subscribe_pool(peer->mailbox, stasis_subscription_cb_noop, NULL);</span><br><span>        }</span><br><span> </span><br><span>        if (subscribe_acl_change) {</span><br><span>diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c</span><br><span>index fa3a081..2c8c525 100644</span><br><span>--- a/channels/chan_mgcp.c</span><br><span>+++ b/channels/chan_mgcp.c</span><br><span>@@ -346,7 +346,7 @@</span><br><span>       char curtone[80];                       /*!< Current tone */</span><br><span>      char mailbox[AST_MAX_EXTENSION];</span><br><span>     char parkinglot[AST_MAX_CONTEXT];   /*!< Parkinglot */</span><br><span style="color: hsl(0, 100%, 40%);">-       struct stasis_subscription *mwi_event_sub;</span><br><span style="color: hsl(120, 100%, 40%);">+    struct ast_mwi_subscriber *mwi_event_sub;</span><br><span>    ast_group_t callgroup;</span><br><span>       ast_group_t pickupgroup;</span><br><span>     int callwaiting;</span><br><span>@@ -4234,18 +4234,11 @@</span><br><span>                           ast_copy_string(e->mailbox, mailbox, sizeof(e->mailbox));</span><br><span>                              ast_copy_string(e->parkinglot, parkinglot, sizeof(e->parkinglot));</span><br><span>                             if (!ast_strlen_zero(e->mailbox)) {</span><br><span style="color: hsl(0, 100%, 40%);">-                                  struct stasis_topic *mailbox_specific_topic;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-                                    mailbox_specific_topic = ast_mwi_topic(e->mailbox);</span><br><span style="color: hsl(0, 100%, 40%);">-                                  if (mailbox_specific_topic) {</span><br><span style="color: hsl(0, 100%, 40%);">-                                           /* This module does not handle MWI in an event-based manner.  However, it</span><br><span style="color: hsl(0, 100%, 40%);">-                                                * subscribes to MWI for each mailbox that is configured so that the core</span><br><span style="color: hsl(0, 100%, 40%);">-                                                * knows that we care about it.  Then, chan_mgcp will get the MWI from the</span><br><span style="color: hsl(0, 100%, 40%);">-                                               * event cache instead of checking the mailbox directly. */</span><br><span style="color: hsl(0, 100%, 40%);">-                                             e->mwi_event_sub = stasis_subscribe_pool(mailbox_specific_topic, stasis_subscription_cb_noop, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-                                         stasis_subscription_accept_message_type(e->mwi_event_sub, ast_mwi_state_type());</span><br><span style="color: hsl(0, 100%, 40%);">-                                             stasis_subscription_set_filter(e->mwi_event_sub, STASIS_SUBSCRIPTION_FILTER_SELECTIVE);</span><br><span style="color: hsl(0, 100%, 40%);">-                                      }</span><br><span style="color: hsl(120, 100%, 40%);">+                                     /* This module does not handle MWI in an event-based manner.  However, it</span><br><span style="color: hsl(120, 100%, 40%);">+                                      * subscribes to MWI for each mailbox that is configured so that the core</span><br><span style="color: hsl(120, 100%, 40%);">+                                      * knows that we care about it.  Then, chan_mgcp will get the MWI from the</span><br><span style="color: hsl(120, 100%, 40%);">+                                     * event cache instead of checking the mailbox directly. */</span><br><span style="color: hsl(120, 100%, 40%);">+                                   e->mwi_event_sub = ast_mwi_subscribe_pool(e->mailbox, stasis_subscription_cb_noop, NULL);</span><br><span>                              }</span><br><span>                            snprintf(e->rqnt_ident, sizeof(e->rqnt_ident), "%08lx", (unsigned long)ast_random());</span><br><span>                                e->msgstate = -1;</span><br><span>@@ -4587,7 +4580,7 @@</span><br><span>         }</span><br><span> </span><br><span>        if (e->mwi_event_sub) {</span><br><span style="color: hsl(0, 100%, 40%);">-              e->mwi_event_sub = stasis_unsubscribe(e->mwi_event_sub);</span><br><span style="color: hsl(120, 100%, 40%);">+                e->mwi_event_sub = ast_mwi_unsubscribe(e->mwi_event_sub);</span><br><span>      }</span><br><span> </span><br><span>        if (e->chanvars) {</span><br><span>diff --git a/channels/chan_sip.c b/channels/chan_sip.c</span><br><span>index cd0db38..eef0d41 100644</span><br><span>--- a/channels/chan_sip.c</span><br><span>+++ b/channels/chan_sip.c</span><br><span>@@ -5251,7 +5251,7 @@</span><br><span> static void destroy_mailbox(struct sip_mailbox *mailbox)</span><br><span> {</span><br><span>      if (mailbox->event_sub) {</span><br><span style="color: hsl(0, 100%, 40%);">-            mailbox->event_sub = stasis_unsubscribe_and_join(mailbox->event_sub);</span><br><span style="color: hsl(120, 100%, 40%);">+           mailbox->event_sub = ast_mwi_unsubscribe_and_join(mailbox->event_sub);</span><br><span>         }</span><br><span>    ast_free(mailbox);</span><br><span> }</span><br><span>@@ -28384,18 +28384,14 @@</span><br><span>  struct sip_mailbox *mailbox;</span><br><span> </span><br><span>     AST_LIST_TRAVERSE(&peer->mailboxes, mailbox, entry) {</span><br><span style="color: hsl(0, 100%, 40%);">-            struct stasis_topic *mailbox_specific_topic;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>                 if (mailbox->status != SIP_MAILBOX_STATUS_NEW) {</span><br><span>                  continue;</span><br><span>            }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-               mailbox_specific_topic = ast_mwi_topic(mailbox->id);</span><br><span style="color: hsl(0, 100%, 40%);">-         if (mailbox_specific_topic) {</span><br><span style="color: hsl(0, 100%, 40%);">-                   mailbox->event_sub = stasis_subscribe_pool(mailbox_specific_topic, mwi_event_cb, peer);</span><br><span style="color: hsl(0, 100%, 40%);">-                      stasis_subscription_accept_message_type(mailbox->event_sub, ast_mwi_state_type());</span><br><span style="color: hsl(0, 100%, 40%);">-                   stasis_subscription_accept_message_type(mailbox->event_sub, stasis_subscription_change_type());</span><br><span style="color: hsl(0, 100%, 40%);">-                      stasis_subscription_set_filter(mailbox->event_sub, STASIS_SUBSCRIPTION_FILTER_SELECTIVE);</span><br><span style="color: hsl(120, 100%, 40%);">+          mailbox->event_sub = ast_mwi_subscribe_pool(mailbox->id, mwi_event_cb, peer);</span><br><span style="color: hsl(120, 100%, 40%);">+           if (mailbox->event_sub) {</span><br><span style="color: hsl(120, 100%, 40%);">+                  stasis_subscription_accept_message_type(</span><br><span style="color: hsl(120, 100%, 40%);">+                              ast_mwi_subscriber_subscription(mailbox->event_sub),</span><br><span style="color: hsl(120, 100%, 40%);">+                               stasis_subscription_change_type());</span><br><span>          }</span><br><span>    }</span><br><span> }</span><br><span>diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c</span><br><span>index fb31c9f..17bc039 100644</span><br><span>--- a/channels/chan_skinny.c</span><br><span>+++ b/channels/chan_skinny.c</span><br><span>@@ -1466,7 +1466,7 @@</span><br><span>  SKINNY_LINE_OPTIONS</span><br><span>  ast_mutex_t lock;</span><br><span>    struct skinny_container *container;</span><br><span style="color: hsl(0, 100%, 40%);">-     struct stasis_subscription *mwi_event_sub; /* Event based MWI */</span><br><span style="color: hsl(120, 100%, 40%);">+      struct ast_mwi_subscriber *mwi_event_sub; /* Event based MWI */</span><br><span>      struct skinny_subchannel *activesub;</span><br><span>         AST_LIST_HEAD(, skinny_subchannel) sub;</span><br><span>      AST_LIST_HEAD(, skinny_subline) sublines;</span><br><span>@@ -8328,16 +8328,8 @@</span><br><span>   config_parse_variables(TYPE_LINE, l, v);</span><br><span> </span><br><span>         if (!ast_strlen_zero(l->mailbox)) {</span><br><span style="color: hsl(0, 100%, 40%);">-          struct stasis_topic *mailbox_specific_topic;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>                 ast_verb(3, "Setting mailbox '%s' on line %s\n", l->mailbox, l->name);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-          mailbox_specific_topic = ast_mwi_topic(l->mailbox);</span><br><span style="color: hsl(0, 100%, 40%);">-          if (mailbox_specific_topic) {</span><br><span style="color: hsl(0, 100%, 40%);">-                   l->mwi_event_sub = stasis_subscribe_pool(mailbox_specific_topic, mwi_event_cb, l);</span><br><span style="color: hsl(0, 100%, 40%);">-                   stasis_subscription_accept_message_type(l->mwi_event_sub, ast_mwi_state_type());</span><br><span style="color: hsl(0, 100%, 40%);">-                     stasis_subscription_set_filter(l->mwi_event_sub, STASIS_SUBSCRIPTION_FILTER_SELECTIVE);</span><br><span style="color: hsl(0, 100%, 40%);">-              }</span><br><span style="color: hsl(120, 100%, 40%);">+             l->mwi_event_sub = ast_mwi_subscribe_pool(l->mailbox, mwi_event_cb, l);</span><br><span>        }</span><br><span> </span><br><span>        if (!ast_strlen_zero(vmexten) && ast_strlen_zero(l->vmexten)) {</span><br><span>@@ -8640,7 +8632,7 @@</span><br><span>              will happen below. */</span><br><span>             while ((l = AST_LIST_REMOVE_HEAD(&d->lines, list))) {</span><br><span>                         if (l->mwi_event_sub) {</span><br><span style="color: hsl(0, 100%, 40%);">-                              l->mwi_event_sub = stasis_unsubscribe(l->mwi_event_sub);</span><br><span style="color: hsl(120, 100%, 40%);">+                                l->mwi_event_sub = ast_mwi_unsubscribe(l->mwi_event_sub);</span><br><span>                      }</span><br><span>            }</span><br><span>            /* Delete all speeddials for this device */</span><br><span>@@ -8797,7 +8789,7 @@</span><br><span>                          skinny_unlocksub(sub);</span><br><span>                       }</span><br><span>                    if (l->mwi_event_sub) {</span><br><span style="color: hsl(0, 100%, 40%);">-                              l->mwi_event_sub = stasis_unsubscribe_and_join(l->mwi_event_sub);</span><br><span style="color: hsl(120, 100%, 40%);">+                               l->mwi_event_sub = ast_mwi_unsubscribe_and_join(l->mwi_event_sub);</span><br><span>                     }</span><br><span>                    ast_mutex_unlock(&l->lock);</span><br><span>                   unregister_exten(l);</span><br><span>diff --git a/channels/sig_pri.c b/channels/sig_pri.c</span><br><span>index 102e3c4..a8c042f 100644</span><br><span>--- a/channels/sig_pri.c</span><br><span>+++ b/channels/sig_pri.c</span><br><span>@@ -8982,7 +8982,7 @@</span><br><span> #if defined(HAVE_PRI_MWI)</span><br><span>       for (idx = 0; idx < ARRAY_LEN(pri->mbox); ++idx) {</span><br><span>             if (pri->mbox[idx].sub) {</span><br><span style="color: hsl(0, 100%, 40%);">-                    pri->mbox[idx].sub = stasis_unsubscribe_and_join(pri->mbox[idx].sub);</span><br><span style="color: hsl(120, 100%, 40%);">+                   pri->mbox[idx].sub = ast_mwi_unsubscribe_and_join(pri->mbox[idx].sub);</span><br><span>                 }</span><br><span>    }</span><br><span> #endif     /* defined(HAVE_PRI_MWI) */</span><br><span>@@ -9051,7 +9051,7 @@</span><br><span>  /* Prepare the mbox[] for use. */</span><br><span>    for (i = 0; i < ARRAY_LEN(pri->mbox); ++i) {</span><br><span>           if (pri->mbox[i].sub) {</span><br><span style="color: hsl(0, 100%, 40%);">-                      pri->mbox[i].sub = stasis_unsubscribe(pri->mbox[i].sub);</span><br><span style="color: hsl(120, 100%, 40%);">+                        pri->mbox[i].sub = ast_mwi_unsubscribe(pri->mbox[i].sub);</span><br><span>              }</span><br><span>    }</span><br><span> #endif     /* defined(HAVE_PRI_MWI) */</span><br><span>@@ -9108,7 +9108,6 @@</span><br><span>  saveptr = pri->mwi_mailboxes;</span><br><span>     for (i = 0; i < ARRAY_LEN(pri->mbox); ++i) {</span><br><span>           char *mbox_id;</span><br><span style="color: hsl(0, 100%, 40%);">-          struct stasis_topic *mailbox_specific_topic;</span><br><span> </span><br><span>             mbox_id = strsep(&saveptr, ",");</span><br><span>               if (mbox_id) {</span><br><span>@@ -9127,16 +9126,10 @@</span><br><span>                     continue;</span><br><span>            }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-           mailbox_specific_topic = ast_mwi_topic(mbox_id);</span><br><span style="color: hsl(0, 100%, 40%);">-                if (mailbox_specific_topic) {</span><br><span style="color: hsl(0, 100%, 40%);">-                   pri->mbox[i].sub = stasis_subscribe_pool(mailbox_specific_topic, sig_pri_mwi_event_cb, pri);</span><br><span style="color: hsl(0, 100%, 40%);">-         }</span><br><span style="color: hsl(120, 100%, 40%);">+             pri->mbox[i].sub = ast_mwi_subscribe_pool(mbox_id, sig_pri_mwi_event_cb, pri);</span><br><span>            if (!pri->mbox[i].sub) {</span><br><span>                  ast_log(LOG_ERROR, "%s span %d could not subscribe to MWI events for %s(%s).\n",</span><br><span>                           sig_pri_cc_type_name, pri->span, pri->mbox[i].vm_box, mbox_id);</span><br><span style="color: hsl(0, 100%, 40%);">-           } else {</span><br><span style="color: hsl(0, 100%, 40%);">-                        stasis_subscription_accept_message_type(pri->mbox[i].sub, ast_mwi_state_type());</span><br><span style="color: hsl(0, 100%, 40%);">-                     stasis_subscription_set_filter(pri->mbox[i].sub, STASIS_SUBSCRIPTION_FILTER_SELECTIVE);</span><br><span>           }</span><br><span> #if defined(HAVE_PRI_MWI_V2)</span><br><span>            if (ast_strlen_zero(pri->mbox[i].vm_number)) {</span><br><span>diff --git a/channels/sig_pri.h b/channels/sig_pri.h</span><br><span>index 8c9babd..497e834 100644</span><br><span>--- a/channels/sig_pri.h</span><br><span>+++ b/channels/sig_pri.h</span><br><span>@@ -424,7 +424,7 @@</span><br><span>          * \brief MWI mailbox event subscription.</span><br><span>     * \note NULL if mailbox not configured.</span><br><span>      */</span><br><span style="color: hsl(0, 100%, 40%);">-     struct stasis_subscription *sub;</span><br><span style="color: hsl(120, 100%, 40%);">+      struct ast_mwi_subscriber *sub;</span><br><span>      /*! \brief Mailbox uniqueid. */</span><br><span>      const char *uniqueid;</span><br><span>        /*! \brief Mailbox number sent to span. */</span><br><span>diff --git a/channels/sip/include/sip.h b/channels/sip/include/sip.h</span><br><span>index 86f8967..4ee2041 100644</span><br><span>--- a/channels/sip/include/sip.h</span><br><span>+++ b/channels/sip/include/sip.h</span><br><span>@@ -1252,7 +1252,7 @@</span><br><span>  */</span><br><span> struct sip_mailbox {</span><br><span>       /*! Associated MWI subscription */</span><br><span style="color: hsl(0, 100%, 40%);">-      struct stasis_subscription *event_sub;</span><br><span style="color: hsl(120, 100%, 40%);">+        struct ast_mwi_subscriber *event_sub;</span><br><span>        AST_LIST_ENTRY(sip_mailbox) entry;</span><br><span>   struct sip_peer *peer;</span><br><span>       enum sip_mailbox_status status;</span><br><span>diff --git a/res/res_pjsip_mwi.c b/res/res_pjsip_mwi.c</span><br><span>index abd7ac0..2ea5f89 100644</span><br><span>--- a/res/res_pjsip_mwi.c</span><br><span>+++ b/res/res_pjsip_mwi.c</span><br><span>@@ -90,7 +90,7 @@</span><br><span>  */</span><br><span> struct mwi_stasis_subscription {</span><br><span>      /*! The MWI stasis subscription */</span><br><span style="color: hsl(0, 100%, 40%);">-      struct stasis_subscription *stasis_sub;</span><br><span style="color: hsl(120, 100%, 40%);">+       struct ast_mwi_subscriber *mwi_subscriber;</span><br><span>   /*! The mailbox corresponding with the MWI subscription. Used as a hash key */</span><br><span>       char mailbox[1];</span><br><span> };</span><br><span>@@ -243,7 +243,6 @@</span><br><span> static struct mwi_stasis_subscription *mwi_stasis_subscription_alloc(const char *mailbox, struct mwi_subscription *mwi_sub)</span><br><span> {</span><br><span>     struct mwi_stasis_subscription *mwi_stasis_sub;</span><br><span style="color: hsl(0, 100%, 40%);">- struct stasis_topic *topic;</span><br><span> </span><br><span>      if (!mwi_sub) {</span><br><span>              return NULL;</span><br><span>@@ -254,26 +253,22 @@</span><br><span>                 return NULL;</span><br><span>         }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   topic = ast_mwi_topic(mailbox);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>      /* Safe strcpy */</span><br><span>    strcpy(mwi_stasis_sub->mailbox, mailbox);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-        ast_debug(3, "Creating stasis MWI subscription to mailbox %s for endpoint %s.  Topic: '%s':%p %d\n",</span><br><span style="color: hsl(0, 100%, 40%);">-          mailbox, mwi_sub->id, stasis_topic_name(topic), topic, (int)ao2_ref(topic, 0));</span><br><span>   ao2_ref(mwi_sub, +1);</span><br><span style="color: hsl(0, 100%, 40%);">-   mwi_stasis_sub->stasis_sub = stasis_subscribe_pool(topic, mwi_stasis_cb, mwi_sub);</span><br><span style="color: hsl(0, 100%, 40%);">-   ao2_ref(topic, -1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     if (!mwi_stasis_sub->stasis_sub) {</span><br><span style="color: hsl(120, 100%, 40%);">+ mwi_stasis_sub->mwi_subscriber = ast_mwi_subscribe_pool(mailbox, mwi_stasis_cb, mwi_sub);</span><br><span style="color: hsl(120, 100%, 40%);">+  if (!mwi_stasis_sub->mwi_subscriber) {</span><br><span>            /* Failed to subscribe. */</span><br><span>           ao2_ref(mwi_stasis_sub, -1);</span><br><span>                 ao2_ref(mwi_sub, -1);</span><br><span style="color: hsl(0, 100%, 40%);">-           mwi_stasis_sub = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+                return NULL;</span><br><span>         }</span><br><span style="color: hsl(0, 100%, 40%);">-       stasis_subscription_accept_message_type(mwi_stasis_sub->stasis_sub, ast_mwi_state_type());</span><br><span style="color: hsl(0, 100%, 40%);">-   stasis_subscription_accept_message_type(mwi_stasis_sub->stasis_sub, stasis_subscription_change_type());</span><br><span style="color: hsl(0, 100%, 40%);">-      stasis_subscription_set_filter(mwi_stasis_sub->stasis_sub, STASIS_SUBSCRIPTION_FILTER_SELECTIVE);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        stasis_subscription_accept_message_type(</span><br><span style="color: hsl(120, 100%, 40%);">+              ast_mwi_subscriber_subscription(mwi_stasis_sub->mwi_subscriber),</span><br><span style="color: hsl(120, 100%, 40%);">+           stasis_subscription_change_type());</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>        return mwi_stasis_sub;</span><br><span> }</span><br><span> </span><br><span>@@ -433,21 +428,19 @@</span><br><span> </span><br><span> static int get_message_count(void *obj, void *arg, int flags)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-       struct stasis_message *msg;</span><br><span>  struct mwi_stasis_subscription *mwi_stasis = obj;</span><br><span>    struct ast_sip_message_accumulator *counter = arg;</span><br><span>   struct ast_mwi_state *mwi_state;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-    msg = stasis_cache_get(ast_mwi_state_cache(), ast_mwi_state_type(), mwi_stasis->mailbox);</span><br><span style="color: hsl(0, 100%, 40%);">-    if (!msg) {</span><br><span style="color: hsl(120, 100%, 40%);">+   mwi_state = ast_mwi_subscriber_data(mwi_stasis->mwi_subscriber);</span><br><span style="color: hsl(120, 100%, 40%);">+   if (!mwi_state) {</span><br><span>            return 0;</span><br><span>    }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   mwi_state = stasis_message_data(msg);</span><br><span>        counter->old_msgs += mwi_state->old_msgs;</span><br><span>      counter->new_msgs += mwi_state->new_msgs;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-     ao2_ref(msg, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+     ao2_ref(mwi_state, -1);</span><br><span> </span><br><span>  return 0;</span><br><span> }</span><br><span>@@ -683,10 +676,11 @@</span><br><span> static int unsubscribe_stasis(void *obj, void *arg, int flags)</span><br><span> {</span><br><span>        struct mwi_stasis_subscription *mwi_stasis = obj;</span><br><span style="color: hsl(0, 100%, 40%);">-       if (mwi_stasis->stasis_sub) {</span><br><span style="color: hsl(120, 100%, 40%);">+      if (mwi_stasis->mwi_subscriber) {</span><br><span>                 ast_debug(3, "Removing stasis subscription to mailbox %s\n", mwi_stasis->mailbox);</span><br><span style="color: hsl(0, 100%, 40%);">-         mwi_stasis->stasis_sub = stasis_unsubscribe_and_join(mwi_stasis->stasis_sub);</span><br><span style="color: hsl(120, 100%, 40%);">+           mwi_stasis->mwi_subscriber = ast_mwi_unsubscribe_and_join(mwi_stasis->mwi_subscriber);</span><br><span>         }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  return CMP_MATCH;</span><br><span> }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11464">change 11464</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/11464"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I32bef880b647246823dbccdf44a98d384fcabfbd </div>
<div style="display:none"> Gerrit-Change-Number: 11464 </div>
<div style="display:none"> Gerrit-PatchSet: 6 </div>
<div style="display:none"> Gerrit-Owner: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>