Changeset 623


Ignore:
Timestamp:
Jul 23, 2006 10:10:35 AM (18 years ago)
Author:
bennylp
Message:

Improvement/bug fix in hash table lookup to allow user to specify the hash value, and modify transaction to take advantage of this feature

Location:
pjproject/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/hash.c

    r583 r623  
    205205{ 
    206206    pj_hash_entry *entry; 
    207  
    208     if (hval) *hval = 0; 
    209207    entry = *find_entry( NULL, ht, key, keylen, NULL, hval, NULL); 
    210208    return entry ? entry->value : NULL; 
  • pjproject/trunk/pjsip-apps/build/pjsip_apps.dsw

    r581 r623  
    208208############################################################################### 
    209209 
     210Project: "test_pjsip"="..\..\pjsip\build\test_pjsip.dsp" - Package Owner=<4> 
     211 
     212Package=<5> 
     213{{{ 
     214}}} 
     215 
     216Package=<4> 
     217{{{ 
     218    Begin Project Dependency 
     219    Project_Dep_Name pjlib 
     220    End Project Dependency 
     221    Begin Project Dependency 
     222    Project_Dep_Name pjlib_util 
     223    End Project Dependency 
     224    Begin Project Dependency 
     225    Project_Dep_Name pjmedia 
     226    End Project Dependency 
     227    Begin Project Dependency 
     228    Project_Dep_Name pjsip_core 
     229    End Project Dependency 
     230    Begin Project Dependency 
     231    Project_Dep_Name pjsip_simple 
     232    End Project Dependency 
     233    Begin Project Dependency 
     234    Project_Dep_Name pjsip_ua 
     235    End Project Dependency 
     236}}} 
     237 
     238############################################################################### 
     239 
    210240Global: 
    211241 
  • pjproject/trunk/pjsip/src/pjsip/sip_transaction.c

    r610 r623  
    3838#define TSX_TRACE_(expr) 
    3939#endif 
     40 
     41/* When this macro is set, transaction will keep the hashed value 
     42 * so that future lookup (to unregister transaction) does not need 
     43 * to recalculate the hash again. It should gains a little bit of 
     44 * performance, so generally we'd want this. 
     45 */ 
     46#define PRECALC_HASH 
    4047 
    4148 
     
    530537 
    531538    /* Register the transaction to the hash table. */ 
    532     //pj_hash_set( tsx->pool, mod_tsx_layer.htable, tsx->transaction_key.ptr, 
    533     //           tsx->transaction_key.slen, tsx->hashed_key, tsx); 
    534     PJ_TODO(USE_PRECALCULATED_HASHED_VALUE); 
     539#ifdef PRECALC_HASH 
     540    pj_hash_set( tsx->pool, mod_tsx_layer.htable, tsx->transaction_key.ptr, 
     541                 tsx->transaction_key.slen, tsx->hashed_key, tsx); 
     542#else 
    535543    pj_hash_set( tsx->pool, mod_tsx_layer.htable, tsx->transaction_key.ptr, 
    536544                 tsx->transaction_key.slen, 0, tsx); 
     545#endif 
    537546 
    538547    /* Unlock mutex. */ 
     
    555564 
    556565    /* Register the transaction to the hash table. */ 
    557     //pj_hash_set( NULL, mod_tsx_layer.htable, tsx->transaction_key.ptr, 
    558     //           tsx->transaction_key.slen, tsx->hashed_key, NULL); 
    559     PJ_TODO(USE_PRECALCULATED_HASHED_VALUE); 
     566#ifdef PRECALC_HASH 
    560567    pj_hash_set( NULL, mod_tsx_layer.htable, tsx->transaction_key.ptr, 
    561                  tsx->transaction_key.slen, 0, NULL); 
     568                 tsx->transaction_key.slen, tsx->hashed_key, NULL); 
     569#else 
     570    pj_hash_set( NULL, mod_tsx_layer.htable, tsx->transaction_key.ptr, 
     571                 tsx->transaction_key.slen, 0, NULL); 
     572#endif 
    562573 
    563574    TSX_TRACE_((THIS_FILE,  
     
    11541165 
    11551166    /* Calculate hashed key value. */ 
    1156     PJ_TODO(OPTIMIZE_TSX_BY_PRECALCULATING_HASHED_KEY_VALUE); 
    1157     /* 
    1158      blp: somehow this yields different hashed value!! 
    1159  
     1167#ifdef PRECALC_HASH 
    11601168    tsx->hashed_key = pj_hash_calc(0, tsx->transaction_key.ptr, 
    11611169                                   tsx->transaction_key.slen); 
    1162      */ 
     1170#endif 
    11631171 
    11641172    PJ_LOG(6, (tsx->obj_name, "tsx_key=%.*s", tsx->transaction_key.slen, 
     
    12831291 
    12841292    /* Calculate hashed key value. */ 
    1285     PJ_TODO(OPTIMIZE_TSX_BY_PRECALCULATING_HASHED_KEY_VALUE); 
    1286     /* 
    1287      blp: somehow this yields different hashed value!! 
    1288  
     1293#ifdef PRECALC_HASH 
    12891294    tsx->hashed_key = pj_hash_calc(0, tsx->transaction_key.ptr, 
    12901295                                   tsx->transaction_key.slen); 
    1291      */ 
     1296#endif 
    12921297 
    12931298    /* Duplicate branch parameter for transaction. */ 
Note: See TracChangeset for help on using the changeset viewer.