Changeset 139 for pjproject/trunk/pjsip/src/pjsip/sip_transaction.c
- Timestamp:
- Feb 7, 2006 12:34:11 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_transaction.c
r130 r139 32 32 33 33 #define THIS_FILE "sip_transaction.c" 34 35 #if 0 36 #define TSX_TRACE_(expr) PJ_LOG(3,expr) 37 #else 38 #define TSX_TRACE_(expr) 39 #endif 40 34 41 35 42 /***************************************************************************** … … 505 512 pj_mutex_lock(mod_tsx_layer.mutex); 506 513 507 /* Check if no transaction with the same key exists. */ 508 PJ_ASSERT_ON_FAIL(pj_hash_get( mod_tsx_layer.htable, 509 &tsx->transaction_key.ptr, 510 tsx->transaction_key.slen, 511 &tsx->hashed_key) == NULL, 512 { 513 pj_mutex_unlock(mod_tsx_layer.mutex); 514 return PJ_EEXISTS; 515 } 516 ); 514 /* Check if no transaction with the same key exists. 515 * Do not use PJ_ASSERT_RETURN since it evaluates the expression 516 * twice! 517 */ 518 pj_assert(pj_hash_get( mod_tsx_layer.htable, 519 &tsx->transaction_key.ptr, 520 tsx->transaction_key.slen, 521 NULL) == NULL); 522 523 TSX_TRACE_((THIS_FILE, 524 "Transaction %p registered with hkey=0x%p and key=%.*s", 525 tsx, tsx->hashed_key, tsx->transaction_key.slen, 526 tsx->transaction_key.ptr)); 517 527 518 528 /* Register the transaction to the hash table. */ 529 //pj_hash_set( tsx->pool, mod_tsx_layer.htable, tsx->transaction_key.ptr, 530 // tsx->transaction_key.slen, tsx->hashed_key, tsx); 531 PJ_TODO(USE_PRECALCULATED_HASHED_VALUE); 519 532 pj_hash_set( tsx->pool, mod_tsx_layer.htable, tsx->transaction_key.ptr, 520 tsx->transaction_key.slen, tsx->hashed_key, tsx);533 tsx->transaction_key.slen, 0, tsx); 521 534 522 535 /* Unlock mutex. */ … … 539 552 540 553 /* Register the transaction to the hash table. */ 554 //pj_hash_set( NULL, mod_tsx_layer.htable, tsx->transaction_key.ptr, 555 // tsx->transaction_key.slen, tsx->hashed_key, NULL); 556 PJ_TODO(USE_PRECALCULATED_HASHED_VALUE); 541 557 pj_hash_set( NULL, mod_tsx_layer.htable, tsx->transaction_key.ptr, 542 tsx->transaction_key.slen, tsx->hashed_key, NULL); 558 tsx->transaction_key.slen, 0, NULL); 559 560 TSX_TRACE_((THIS_FILE, 561 "Transaction %p unregistered, hkey=0x%p and key=%.*s", 562 tsx, tsx->hashed_key, tsx->transaction_key.slen, 563 tsx->transaction_key.ptr)); 543 564 544 565 /* Unlock mutex. */ … … 554 575 { 555 576 pjsip_transaction *tsx; 577 pj_uint32_t hval = 0; 556 578 557 579 pj_mutex_lock(mod_tsx_layer.mutex); 558 tsx = pj_hash_get( mod_tsx_layer.htable, key->ptr, key->slen, NULL);580 tsx = pj_hash_get( mod_tsx_layer.htable, key->ptr, key->slen, &hval ); 559 581 pj_mutex_unlock(mod_tsx_layer.mutex); 560 582 583 TSX_TRACE_((THIS_FILE, 584 "Finding tsx with hkey=0x%p and key=%.*s: found %p", 585 hval, key->slen, key->ptr, tsx)); 561 586 562 587 /* Race condition! … … 642 667 { 643 668 pj_str_t key; 669 pj_uint32_t hval = 0; 644 670 pjsip_transaction *tsx; 645 671 … … 650 676 pj_mutex_lock( mod_tsx_layer.mutex ); 651 677 652 tsx = pj_hash_get( mod_tsx_layer.htable, key.ptr, key.slen, NULL ); 678 tsx = pj_hash_get( mod_tsx_layer.htable, key.ptr, key.slen, &hval ); 679 680 681 TSX_TRACE_((THIS_FILE, 682 "Finding tsx for request, hkey=0x%p and key=%.*s, found %p", 683 hval, key.slen, key.ptr, tsx)); 684 653 685 654 686 if (tsx == NULL || tsx->state == PJSIP_TSX_STATE_TERMINATED) { … … 683 715 { 684 716 pj_str_t key; 717 pj_uint32_t hval = 0; 685 718 pjsip_transaction *tsx; 686 719 … … 691 724 pj_mutex_lock( mod_tsx_layer.mutex ); 692 725 693 tsx = pj_hash_get( mod_tsx_layer.htable, key.ptr, key.slen, NULL ); 726 tsx = pj_hash_get( mod_tsx_layer.htable, key.ptr, key.slen, &hval ); 727 728 729 TSX_TRACE_((THIS_FILE, 730 "Finding tsx for response, hkey=0x%p and key=%.*s, found %p", 731 hval, key.slen, key.ptr, tsx)); 732 694 733 695 734 if (tsx == NULL || tsx->state == PJSIP_TSX_STATE_TERMINATED) { … … 919 958 } 920 959 921 /* Inform TU */ 960 /* Before informing TU about state changed, inform TU about 961 * rx event. 962 */ 963 if (event_src_type==PJSIP_EVENT_RX_MSG && tsx->tsx_user) { 964 pjsip_rx_data *rdata = event_src; 965 966 pj_assert(rdata != NULL); 967 968 if (rdata->msg_info.msg->type == PJSIP_REQUEST_MSG && 969 tsx->tsx_user->on_rx_request) 970 { 971 (*tsx->tsx_user->on_rx_request)(rdata); 972 973 } else if (rdata->msg_info.msg->type == PJSIP_RESPONSE_MSG && 974 tsx->tsx_user->on_rx_response) 975 { 976 (*tsx->tsx_user->on_rx_response)(rdata); 977 } 978 979 } 980 981 /* Inform TU about state changed. */ 922 982 if (tsx->tsx_user && tsx->tsx_user->on_tsx_state) { 923 983 pjsip_event e; … … 1045 1105 1046 1106 /* Calculate hashed key value. */ 1107 PJ_TODO(OPTIMIZE_TSX_BY_PRECALCULATING_HASHED_KEY_VALUE); 1108 /* 1109 blp: somehow this yields different hashed value!! 1110 1047 1111 tsx->hashed_key = pj_hash_calc(0, tsx->transaction_key.ptr, 1048 1112 tsx->transaction_key.slen); 1113 */ 1049 1114 1050 1115 PJ_LOG(6, (tsx->obj_name, "tsx_key=%.*s", tsx->transaction_key.slen, … … 1159 1224 1160 1225 /* Calculate hashed key value. */ 1226 PJ_TODO(OPTIMIZE_TSX_BY_PRECALCULATING_HASHED_KEY_VALUE); 1227 /* 1228 blp: somehow this yields different hashed value!! 1229 1161 1230 tsx->hashed_key = pj_hash_calc(0, tsx->transaction_key.ptr, 1162 1231 tsx->transaction_key.slen); 1232 */ 1163 1233 1164 1234 /* Duplicate branch parameter for transaction. */
Note: See TracChangeset
for help on using the changeset viewer.