Changeset 212 for pjproject/trunk/pjsip/src/pjsip/sip_dialog.c
- Timestamp:
- Feb 21, 2006 11:47:00 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_dialog.c
r196 r212 79 79 dlg->state = PJSIP_DIALOG_STATE_NULL; 80 80 81 pj_list_init(&dlg->inv_hdr); 82 81 83 status = pj_mutex_create_recursive(pool, "dlg%p", &dlg->mutex); 82 84 if (status != PJ_SUCCESS) … … 132 134 } 133 135 136 /* Put any header param in the target URI into INVITE header list. */ 137 if (PJSIP_URI_SCHEME_IS_SIP(dlg->target) || 138 PJSIP_URI_SCHEME_IS_SIPS(dlg->target)) 139 { 140 pjsip_param *param; 141 pjsip_sip_uri *uri = (pjsip_sip_uri*)pjsip_uri_get_uri(dlg->target); 142 143 param = uri->header_param.next; 144 while (param != &uri->header_param) { 145 pjsip_generic_string_hdr *req_hdr; 146 147 req_hdr = pjsip_generic_string_hdr_create(dlg->pool, ¶m->name, 148 ¶m->value); 149 pj_list_push_back(&dlg->inv_hdr, req_hdr); 150 151 param = param->next; 152 } 153 } 154 134 155 /* Init local info. */ 135 156 dlg->local.info = pjsip_from_hdr_create(dlg->pool); 136 pj_strdup_with_null(dlg->pool, &tmp, local_uri); 137 dlg->local.info->uri = pjsip_parse_uri(dlg->pool, tmp.ptr, tmp.slen, 0); 157 pj_strdup_with_null(dlg->pool, &dlg->local.info_str, local_uri); 158 dlg->local.info->uri = pjsip_parse_uri(dlg->pool, 159 dlg->local.info_str.ptr, 160 dlg->local.info_str.slen, 0); 138 161 if (!dlg->local.info->uri) { 139 162 status = PJSIP_EINVALIDURI; … … 165 188 /* Init remote info. */ 166 189 dlg->remote.info = pjsip_to_hdr_create(dlg->pool); 167 pj_strdup_with_null(dlg->pool, &tmp, remote_uri); 168 dlg->remote.info->uri = pjsip_parse_uri(dlg->pool, tmp.ptr, tmp.slen, 0); 190 pj_strdup_with_null(dlg->pool, &dlg->remote.info_str, remote_uri); 191 dlg->remote.info->uri = pjsip_parse_uri(dlg->pool, 192 dlg->remote.info_str.ptr, 193 dlg->remote.info_str.slen, 0); 169 194 if (!dlg->remote.info->uri) { 170 195 status = PJSIP_EINVALIDURI; … … 226 251 pjsip_rr_hdr *rr; 227 252 pjsip_transaction *tsx = NULL; 253 pj_str_t tmp; 254 enum { TMP_LEN=128}; 255 pj_ssize_t len; 228 256 pjsip_dialog *dlg; 229 257 … … 250 278 return status; 251 279 280 /* Temprary string for getting the string representation of 281 * both local and remote URI. 282 */ 283 tmp.ptr = pj_pool_alloc(rdata->tp_info.pool, TMP_LEN); 284 252 285 /* Init local info from the To header. */ 253 286 dlg->local.info = pjsip_hdr_clone(dlg->pool, rdata->msg_info.to); … … 257 290 pj_create_unique_string(dlg->pool, &dlg->local.info->tag); 258 291 292 293 /* Print the local info. */ 294 len = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, 295 dlg->local.info->uri, tmp.ptr, TMP_LEN); 296 if (len < 1) { 297 pj_ansi_strcpy(tmp.ptr, "<-error: uri too long->"); 298 tmp.slen = pj_ansi_strlen(tmp.ptr); 299 } else 300 tmp.slen = len; 301 302 /* Save the local info. */ 303 pj_strdup(dlg->pool, &dlg->local.info_str, &tmp); 304 259 305 /* Calculate hash value of local tag. */ 260 306 dlg->local.tag_hval = pj_hash_calc(0, dlg->local.info->tag.ptr, 261 307 dlg->local.info->tag.slen); 308 309 /* Print the local info. */ 310 len = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, 311 dlg->local.info->uri, tmp.ptr, TMP_LEN); 312 if (len < 1) { 313 pj_ansi_strcpy(tmp.ptr, "<-error: uri too long->"); 314 tmp.slen = pj_ansi_strlen(tmp.ptr); 315 } else 316 tmp.slen = len; 317 318 /* Save the local info. */ 319 pj_strdup(dlg->pool, &dlg->remote.info_str, &tmp); 320 262 321 263 322 /* Randomize local cseq */ … … 1086 1145 pjsip_tx_data *tdata) 1087 1146 { 1147 pj_status_t status; 1148 1088 1149 /* Sanity check. */ 1089 1150 PJ_ASSERT_RETURN(dlg && tsx && tdata && tdata->msg, PJ_EINVAL); … … 1108 1169 #endif 1109 1170 1110 return pjsip_tsx_send_msg(tsx, tdata); 1171 /* Must acquire dialog first, to prevent deadlock */ 1172 pjsip_dlg_inc_lock(dlg); 1173 1174 status = pjsip_tsx_send_msg(tsx, tdata); 1175 1176 pjsip_dlg_dec_lock(dlg); 1177 1178 return status; 1111 1179 } 1112 1180
Note: See TracChangeset
for help on using the changeset viewer.