diff options
author | Matt Jordan <mjordan@digium.com> | 2015-07-16 20:33:34 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2015-07-16 20:33:34 -0500 |
commit | 174f0e9d4d8cd6fbc0fd902b524b41b8420bb818 (patch) | |
tree | 7c509fe3aaaf8c9e6950b2c2f141fbeefd96761d | |
parent | bba2c44ac44d6309649262abc90533bd6df5aace (diff) | |
parent | 3d0ca343ca4c3f81e8739bc5a7aaed12b89a207e (diff) |
Merge "res_pjsip_session.c: Add some helpful comments and minor tweaks." into 13
-rw-r--r-- | res/res_pjsip_session.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c index e6ed64520..f2f2fc968 100644 --- a/res/res_pjsip_session.c +++ b/res/res_pjsip_session.c @@ -1212,8 +1212,9 @@ static int add_supplements(struct ast_sip_session *session) static int add_session_media(void *obj, void *arg, int flags) { struct sdp_handler_list *handler_list = obj; - struct ast_sip_session * session = arg; + struct ast_sip_session *session = arg; RAII_VAR(struct ast_sip_session_media *, session_media, NULL, ao2_cleanup); + session_media = ao2_alloc(sizeof(*session_media) + strlen(handler_list->stream_type), session_media_dtor); if (!session_media) { return CMP_STOP; @@ -1253,9 +1254,11 @@ struct ast_sip_channel_pvt *ast_sip_channel_pvt_alloc(void *pvt, struct ast_sip_ struct ast_sip_session *ast_sip_session_alloc(struct ast_sip_endpoint *endpoint, struct ast_sip_contact *contact, pjsip_inv_session *inv_session) { - RAII_VAR(struct ast_sip_session *, session, ao2_alloc(sizeof(*session), session_destructor), ao2_cleanup); + RAII_VAR(struct ast_sip_session *, session, NULL, ao2_cleanup); struct ast_sip_session_supplement *iter; int dsp_features = 0; + + session = ao2_alloc(sizeof(*session), session_destructor); if (!session) { return NULL; } @@ -1296,6 +1299,7 @@ struct ast_sip_session *ast_sip_session_alloc(struct ast_sip_endpoint *endpoint, if (dsp_features) { if (!(session->dsp = ast_dsp_new())) { + /* Release the ref held by session->inv_session */ ao2_ref(session, -1); return NULL; } @@ -1304,6 +1308,7 @@ struct ast_sip_session *ast_sip_session_alloc(struct ast_sip_endpoint *endpoint, } if (add_supplements(session)) { + /* Release the ref held by session->inv_session */ ao2_ref(session, -1); return NULL; } @@ -2280,6 +2285,8 @@ static int session_end_completion(void *vsession) ast_sip_dialog_set_serializer(session->inv_session->dlg, NULL); ast_sip_dialog_set_endpoint(session->inv_session->dlg, NULL); + + /* Now we can release the ref that was held by session->inv_session */ ao2_cleanup(session); return 0; } |