diff options
author | Benny Prijono <bennylp@teluu.com> | 2010-01-21 10:04:26 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2010-01-21 10:04:26 +0000 |
commit | 0535be243fddf29f4ab4164cbe1b67d59d59b250 (patch) | |
tree | 90c897205aab455ed7d405bd47e9ae82cbd9a3b3 /pjsip/src/pjsip-simple/evsub.c | |
parent | 29f2c32efa33d5126e53ee1afba31f967517cf1e (diff) |
Ticket #1029: Fix support for multiple (event) subscriptions in a single dialog (thanks Wang Eric for the report)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3068 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsip-simple/evsub.c')
-rw-r--r-- | pjsip/src/pjsip-simple/evsub.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/pjsip/src/pjsip-simple/evsub.c b/pjsip/src/pjsip-simple/evsub.c index 7acd0bad..c52b0b5f 100644 --- a/pjsip/src/pjsip-simple/evsub.c +++ b/pjsip/src/pjsip-simple/evsub.c @@ -735,25 +735,33 @@ static pj_status_t evsub_create( pjsip_dialog *dlg, pj_strdup(sub->pool, &sub->event->event_type, event); - /* Create subcription list: */ - - dlgsub_head = PJ_POOL_ALLOC_T(sub->pool, struct dlgsub); - dlgsub = PJ_POOL_ALLOC_T(sub->pool, struct dlgsub); - dlgsub->sub = sub; + /* Check if another subscription has been registered to the dialog. In + * that case, just add ourselves to the subscription list, otherwise + * create and register a new subscription list. + */ + if (pjsip_dlg_has_usage(dlg, &mod_evsub.mod)) { + dlgsub_head = (struct dlgsub*) dlg->mod_data[mod_evsub.mod.id]; + dlgsub = PJ_POOL_ALLOC_T(sub->pool, struct dlgsub); + dlgsub->sub = sub; + pj_list_push_back(dlgsub_head, dlgsub); + } else { + dlgsub_head = PJ_POOL_ALLOC_T(sub->pool, struct dlgsub); + dlgsub = PJ_POOL_ALLOC_T(sub->pool, struct dlgsub); + dlgsub->sub = sub; - pj_list_init(dlgsub_head); - pj_list_push_back(dlgsub_head, dlgsub); + pj_list_init(dlgsub_head); + pj_list_push_back(dlgsub_head, dlgsub); - /* Register as dialog usage: */ + /* Register as dialog usage: */ - status = pjsip_dlg_add_usage(dlg, &mod_evsub.mod, dlgsub_head); - if (status != PJ_SUCCESS) { - pjsip_dlg_dec_lock(dlg); - return status; + status = pjsip_dlg_add_usage(dlg, &mod_evsub.mod, dlgsub_head); + if (status != PJ_SUCCESS) { + pjsip_dlg_dec_lock(dlg); + return status; + } } - PJ_LOG(5,(sub->obj_name, "%s subscription created, using dialog %s", (role==PJSIP_ROLE_UAC ? "UAC" : "UAS"), dlg->obj_name)); |