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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.