Changeset 14:14cf6daf716d in freeDiameter for libfreeDiameter/sessions.c
- Timestamp:
- Oct 1, 2009, 6:24:07 PM (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfreeDiameter/sessions.c
r7 r14 117 117 118 118 /* Expiring sessions management */ 119 static struct fd_list exp_sentinel ; /* list of sessions ordered by their timeout date */119 static struct fd_list exp_sentinel = FD_LIST_INITIALIZER(exp_sentinel); /* list of sessions ordered by their timeout date */ 120 120 static pthread_mutex_t exp_lock = PTHREAD_MUTEX_INITIALIZER; /* lock protecting the list. */ 121 121 static pthread_cond_t exp_cond = PTHREAD_COND_INITIALIZER; /* condvar used by the expiry mecahinsm. */ … … 231 231 } 232 232 233 /* Initialize expiry management */ 234 fd_list_init( &exp_sentinel, NULL ); 233 /* Start session garbage collector (expiry) */ 235 234 CHECK_POSIX( pthread_create(&exp_thr, NULL, exp_fct, NULL) ); 236 235 … … 266 265 { 267 266 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 ); 269 269 int i; 270 270 … … 274 274 del = *handler; 275 275 *handler = NULL; 276 fd_list_init(&deleted_states, NULL);277 276 278 277 del->eyec = 0xdead; /* The handler is not valid anymore for any other operation */ … … 413 412 fd_list_insert_after( li, &sess->expire ); 414 413 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 415 419 #if 0 416 420 if (TRACE_BOOL(ANNOYING)) { … … 424 428 #endif 425 429 426 /* We added a new expiring element, we must signal */427 CHECK_POSIX( pthread_cond_signal(&exp_cond) );428 429 430 /* We're done */ 430 431 CHECK_POSIX( pthread_mutex_unlock( &exp_lock ) ); … … 506 507 fd_list_insert_before( li, &session->expire ); 507 508 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 } 510 513 511 514 #if 0 … … 588 591 } 589 592 590 591 592 593 /* Save a state information with a session */ 593 594 int 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.