Navigation


Changeset 556:8c9028ec02bf in freeDiameter


Ignore:
Timestamp:
Sep 15, 2010, 5:27:07 PM (14 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Preparing for bugfix release 1.0.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfreeDiameter/sessions.c

    r453 r556  
    9494        uint32_t        hash;   /* computed hash of sid */
    9595        struct fd_list  chain_h;/* chaining in the hash table of sessions. */
     96        int             rc;     /* Reference counter on this object, freed only when it reaches 0. */
    9697       
    9798        struct timespec timeout;/* Timeout date for the session */
     
    100101        pthread_mutex_t stlock; /* A lock to protect the list of states associated with this session */
    101102        struct fd_list  states; /* Sentinel for the list of states of this session. */
    102         int             msg_cnt;/* Reference counter for the messages pointing to this session */
    103103};
    104104
    105105/* Sessions hash table, to allow fast sid to session retrieval */
    106106static struct {
    107         struct fd_list  sentinel;       /* sentinel element for this sublist */
    108         pthread_mutex_t lock;           /* the mutex for this sublist -- we might probably change it to rwlock for a little optimization */
     107        struct fd_list   sentinel;      /* sentinel element for this sublist */
     108        pthread_rwlock_t rwlock;        /* the rwlock for this sublist */
    109109} sess_hash [ 1 << SESS_HASH_SIZE ] ;
    110110#define H_MASK( __hash ) ((__hash) & (( 1 << SESS_HASH_SIZE ) - 1))
    111 #define H_LIST( _hash ) (&(sess_hash[H_MASK(_hash)].sentinel))
    112 #define H_LOCK( _hash ) (&(sess_hash[H_MASK(_hash)].lock    ))
     111#define H_LIST( _hash )   (&(sess_hash[H_MASK(_hash)].sentinel))
     112#define H_RWLOCK( _hash ) (&(sess_hash[H_MASK(_hash)].rwlock  ))
    113113
    114114/* The following are used to generate sid values that are eternaly unique */
     
    127127 * i.e. state lock can be taken while holding the hash lock, but not while holding the expiry lock.
    128128 * As well, the hash lock cannot be taken while holding a state lock.
     129 * Never try to take another lock while holding the expiry one.
    129130 */
    130131
     
    147148        sess->hash = fd_hash(sid, sidlen);
    148149        fd_list_init(&sess->chain_h, sess);
     150        sess->rc   = 0;
    149151       
    150152        CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &sess->timeout), return NULL );
Note: See TracChangeset for help on using the changeset viewer.