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 */