this is only called by server new */
| 343 | |
| 344 | /* this is only called by server new */ |
| 345 | str* b2b_htable_insert(b2b_table table, b2b_dlg_t* dlg, int hash_index, |
| 346 | str *init_b2b_key, int src, int safe, int db_insert, unsigned int ua_timeout) |
| 347 | { |
| 348 | b2b_dlg_t * it, *prev_it= NULL; |
| 349 | str* b2b_key; |
| 350 | |
| 351 | if(!safe) |
| 352 | B2BE_LOCK_GET(table, hash_index); |
| 353 | |
| 354 | dlg->prev = dlg->next = NULL; |
| 355 | it = table[hash_index].first; |
| 356 | |
| 357 | if(it == NULL) |
| 358 | { |
| 359 | table[hash_index].first = dlg; |
| 360 | } |
| 361 | else |
| 362 | { |
| 363 | while(it) |
| 364 | { |
| 365 | prev_it = it; |
| 366 | it = it->next; |
| 367 | } |
| 368 | prev_it->next = dlg; |
| 369 | dlg->prev = prev_it; |
| 370 | } |
| 371 | if (!init_b2b_key) { |
| 372 | /* if an insert in server_htable -> copy the b2b_key in the to_tag */ |
| 373 | b2b_key = b2b_generate_key(hash_index, dlg->id); |
| 374 | if(b2b_key == NULL) |
| 375 | { |
| 376 | if(!safe) |
| 377 | B2BE_LOCK_RELEASE(table, hash_index); |
| 378 | LM_ERR("Failed to generate b2b key\n"); |
| 379 | return NULL; |
| 380 | } |
| 381 | } else { |
| 382 | b2b_key = init_b2b_key; |
| 383 | } |
| 384 | |
| 385 | if(src == B2B_SERVER) |
| 386 | { |
| 387 | dlg->tag[CALLEE_LEG].s = (char*)shm_malloc(b2b_key->len); |
| 388 | if(dlg->tag[CALLEE_LEG].s == NULL) |
| 389 | { |
| 390 | LM_ERR("No more shared memory\n"); |
| 391 | if(!safe) |
| 392 | B2BE_LOCK_RELEASE(table, hash_index); |
| 393 | goto err_free; |
| 394 | } |
| 395 | memcpy(dlg->tag[CALLEE_LEG].s, b2b_key->s, b2b_key->len); |
| 396 | dlg->tag[CALLEE_LEG].len = b2b_key->len; |
| 397 | } |
| 398 | |
| 399 | if (dlg->ua_flags&UA_FL_IS_UA_ENTITY) { |
| 400 | if (ua_timeout == 0) |
| 401 | ua_timeout = ua_default_timeout; |
| 402 | dlg->ua_timer_list = insert_ua_sess_tl(b2b_key, ua_timeout); |
no test coverage detected