|
@@ -766,7 +766,6 @@ int dlg_new_dialog(sip_msg_t *req, struct cell *t, const int run_initial_cbs)
|
|
str ttag;
|
|
str ttag;
|
|
str req_uri;
|
|
str req_uri;
|
|
unsigned int dir;
|
|
unsigned int dir;
|
|
- int mlock;
|
|
|
|
|
|
|
|
dlg = dlg_get_ctx_dialog();
|
|
dlg = dlg_get_ctx_dialog();
|
|
if(dlg != NULL) {
|
|
if(dlg != NULL) {
|
|
@@ -792,14 +791,10 @@ int dlg_new_dialog(sip_msg_t *req, struct cell *t, const int run_initial_cbs)
|
|
trim(&req_uri);
|
|
trim(&req_uri);
|
|
|
|
|
|
dir = DLG_DIR_NONE;
|
|
dir = DLG_DIR_NONE;
|
|
- mlock = 1;
|
|
|
|
/* search dialog by SIP attributes
|
|
/* search dialog by SIP attributes
|
|
- * - if not found, hash table slot is left locked, to avoid races
|
|
|
|
- * to add 'same' dialog on parallel forking or not-handled-yet
|
|
|
|
- * retransmissions. Release slot after linking new dialog */
|
|
|
|
- dlg = search_dlg(&callid, &ftag, &ttag, &dir);
|
|
|
|
|
|
+ * - hash table slot is left locked */
|
|
|
|
+ dlg = dlg_search(&callid, &ftag, &ttag, &dir);
|
|
if(dlg) {
|
|
if(dlg) {
|
|
- mlock = 0;
|
|
|
|
if (detect_spirals) {
|
|
if (detect_spirals) {
|
|
if (spiral_detected == 1)
|
|
if (spiral_detected == 1)
|
|
return 0;
|
|
return 0;
|
|
@@ -817,13 +812,11 @@ int dlg_new_dialog(sip_msg_t *req, struct cell *t, const int run_initial_cbs)
|
|
_dlg_ctx.iuid.h_id = dlg->h_id;
|
|
_dlg_ctx.iuid.h_id = dlg->h_id;
|
|
/* search_dlg() has incremented the ref count by 1 */
|
|
/* search_dlg() has incremented the ref count by 1 */
|
|
dlg_release(dlg);
|
|
dlg_release(dlg);
|
|
|
|
+ dlg_hash_release(&callid);
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
dlg_release(dlg);
|
|
dlg_release(dlg);
|
|
}
|
|
}
|
|
- /* lock the slot - dlg found, but in dlg_state_deleted, do a new one */
|
|
|
|
- dlg_hash_lock(&callid);
|
|
|
|
- mlock = 1;
|
|
|
|
}
|
|
}
|
|
spiral_detected = 0;
|
|
spiral_detected = 0;
|
|
|
|
|
|
@@ -834,7 +827,7 @@ int dlg_new_dialog(sip_msg_t *req, struct cell *t, const int run_initial_cbs)
|
|
&req_uri /*r-uri*/ );
|
|
&req_uri /*r-uri*/ );
|
|
|
|
|
|
if (dlg==0) {
|
|
if (dlg==0) {
|
|
- if(likely(mlock==1)) dlg_hash_release(&callid);
|
|
|
|
|
|
+ dlg_hash_release(&callid);
|
|
LM_ERR("failed to create new dialog\n");
|
|
LM_ERR("failed to create new dialog\n");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
@@ -842,7 +835,7 @@ int dlg_new_dialog(sip_msg_t *req, struct cell *t, const int run_initial_cbs)
|
|
/* save caller's tag, cseq, contact and record route*/
|
|
/* save caller's tag, cseq, contact and record route*/
|
|
if (populate_leg_info(dlg, req, t, DLG_CALLER_LEG,
|
|
if (populate_leg_info(dlg, req, t, DLG_CALLER_LEG,
|
|
&(get_from(req)->tag_value)) !=0) {
|
|
&(get_from(req)->tag_value)) !=0) {
|
|
- if(likely(mlock==1)) dlg_hash_release(&callid);
|
|
|
|
|
|
+ dlg_hash_release(&callid);
|
|
LM_ERR("could not add further info to the dialog\n");
|
|
LM_ERR("could not add further info to the dialog\n");
|
|
shm_free(dlg);
|
|
shm_free(dlg);
|
|
return -1;
|
|
return -1;
|
|
@@ -851,9 +844,10 @@ int dlg_new_dialog(sip_msg_t *req, struct cell *t, const int run_initial_cbs)
|
|
/* Populate initial varlist: */
|
|
/* Populate initial varlist: */
|
|
dlg->vars = get_local_varlist_pointer(req, 1);
|
|
dlg->vars = get_local_varlist_pointer(req, 1);
|
|
|
|
|
|
- /* if search_dlg() returned NULL, slot was kept locked */
|
|
|
|
- link_dlg(dlg, 0, mlock);
|
|
|
|
- if(likely(mlock==1)) dlg_hash_release(&callid);
|
|
|
|
|
|
+ /* after dlg_search() slot was kept locked */
|
|
|
|
+ link_dlg(dlg, 0, 0);
|
|
|
|
+ /* unlock after dlg_search() */
|
|
|
|
+ dlg_hash_release(&callid);
|
|
|
|
|
|
dlg->lifetime = get_dlg_timeout(req);
|
|
dlg->lifetime = get_dlg_timeout(req);
|
|
s.s = _dlg_ctx.to_route_name;
|
|
s.s = _dlg_ctx.to_route_name;
|