Merge "res_pjsip/pjsip_distributor.c: Add missing off-nominal request response."
authorJenkins2 <jenkins2@gerrit.asterisk.org>
Thu, 3 May 2018 16:32:08 +0000 (11:32 -0500)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Thu, 3 May 2018 16:32:08 +0000 (11:32 -0500)
1  2 
res/res_pjsip/pjsip_distributor.c

@@@ -734,16 -731,15 +734,17 @@@ static pj_bool_t endpoint_lookup(pjsip_
                        ao2_ref(unid, -1);
                } else if (using_auth_username) {
                        ao2_wrlock(unidentified_requests);
 -                      /* The check again with the write lock held allows us to eliminate the DUPS_REPLACE and sort_fn */
 -                      if ((unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY | OBJ_NOLOCK))) {
 +                      /* Checking again with the write lock held allows us to eliminate the DUPS_REPLACE and sort_fn */
 +                      unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name,
 +                              OBJ_SEARCH_KEY | OBJ_NOLOCK);
 +                      if (unid) {
                                check_endpoint(rdata, unid, name);
                        } else {
 -                              unid = ao2_alloc_options(sizeof(*unid) + strlen(rdata->pkt_info.src_name) + 1, NULL,
 -                                      AO2_ALLOC_OPT_LOCK_RWLOCK);
 +                              unid = ao2_alloc_options(sizeof(*unid) + strlen(rdata->pkt_info.src_name) + 1,
 +                                      NULL, AO2_ALLOC_OPT_LOCK_RWLOCK);
                                if (!unid) {
                                        ao2_unlock(unidentified_requests);
+                                       pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 500, NULL, NULL, NULL);
                                        return PJ_TRUE;
                                }
                                strcpy(unid->src_name, rdata->pkt_info.src_name); /* Safe */