Navigation


Changeset 14:14cf6daf716d in freeDiameter for libfreeDiameter/sessions.c


Ignore:
Timestamp:
Oct 1, 2009, 6:24:07 PM (15 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Some progress on peers module

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfreeDiameter/sessions.c

    r7 r14  
    117117
    118118/* Expiring sessions management */
    119 static struct fd_list   exp_sentinel;   /* list of sessions ordered by their timeout date */
     119static struct fd_list   exp_sentinel = FD_LIST_INITIALIZER(exp_sentinel);       /* list of sessions ordered by their timeout date */
    120120static pthread_mutex_t  exp_lock = PTHREAD_MUTEX_INITIALIZER;   /* lock protecting the list. */
    121121static pthread_cond_t   exp_cond = PTHREAD_COND_INITIALIZER;    /* condvar used by the expiry mecahinsm. */
     
    231231        }
    232232       
    233         /* Initialize expiry management */
    234         fd_list_init( &exp_sentinel, NULL );
     233        /* Start session garbage collector (expiry) */
    235234        CHECK_POSIX(  pthread_create(&exp_thr, NULL, exp_fct, NULL)  );
    236235       
     
    266265{
    267266        struct session_handler * del;
    268         struct fd_list deleted_states; /* Save the list of states to be cleaned up. We do it after finding them to avoid deadlocks. the "o" field becomes a copy of the sid. */
     267        /* place to save the list of states to be cleaned up. We do it after finding them to avoid deadlocks. the "o" field becomes a copy of the sid. */
     268        struct fd_list deleted_states = FD_LIST_INITIALIZER( deleted_states );
    269269        int i;
    270270       
     
    274274        del = *handler;
    275275        *handler = NULL;
    276         fd_list_init(&deleted_states, NULL);
    277276       
    278277        del->eyec = 0xdead; /* The handler is not valid anymore for any other operation */
     
    413412                fd_list_insert_after( li, &sess->expire );
    414413
     414                /* We added a new expiring element, we must signal */
     415                if (li == &exp_sentinel) {
     416                        CHECK_POSIX( pthread_cond_signal(&exp_cond) );
     417                }
     418               
    415419                #if 0
    416420                if (TRACE_BOOL(ANNOYING)) {     
     
    424428                #endif
    425429               
    426                 /* We added a new expiring element, we must signal */
    427                 CHECK_POSIX( pthread_cond_signal(&exp_cond) );
    428                
    429430                /* We're done */
    430431                CHECK_POSIX( pthread_mutex_unlock( &exp_lock ) );
     
    506507        fd_list_insert_before( li, &session->expire );
    507508
    508         /* We added a new expiring element, we must signal */
    509         CHECK_POSIX( pthread_cond_signal(&exp_cond) );
     509        /* We added a new expiring element, we must signal if it was in first position */
     510        if (session->expire.prev == &exp_sentinel) {
     511                CHECK_POSIX( pthread_cond_signal(&exp_cond) );
     512        }
    510513
    511514        #if 0
     
    588591}
    589592
    590 
    591 
    592593/* Save a state information with a session */
    593594int fd_sess_state_store_internal ( struct session_handler * handler, struct session * session, session_state ** state )
Note: See TracChangeset for help on using the changeset viewer.