Navigation


Changeset 778:003df4a9ade2 in freeDiameter for libfdproto/sessions.c


Ignore:
Timestamp:
Jan 22, 2012, 12:11:34 AM (12 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfdproto/sessions.c

    r740 r778  
    115115#define H_LOCK( _hash ) (&(sess_hash[H_MASK(_hash)].lock    ))
    116116
     117static uint32_t         sess_cnt = 0; /* counts all active session (that are in the expiry list) */
     118
    117119/* The following are used to generate sid values that are eternaly unique */
    118120static uint32_t         sid_h;  /* initialized to the current time in fd_sess_init */
     
    485487        }
    486488        fd_list_insert_after( li, &sess->expire );
     489        sess_cnt++;
    487490
    488491        /* We added a new expiring element, we must signal */
     
    612615        /* Unlink from the expiry list */
    613616        CHECK_POSIX_DO( pthread_mutex_lock( &exp_lock ), { ASSERT(0); /* otherwise cleanup handler is not pop'd */ } );
    614         fd_list_unlink( &sess->expire ); /* no need to signal the condition here */
     617        if (!FD_IS_LIST_EMPTY(&sess->expire)) {
     618                sess_cnt--;
     619                fd_list_unlink( &sess->expire ); /* no need to signal the condition here */
     620        }
    615621        CHECK_POSIX_DO( pthread_mutex_unlock( &exp_lock ), { ASSERT(0); /* otherwise cleanup handler is not pop'd */ } );
    616622       
     
    890896        fd_log_debug("\t  %*s -- end of handler @%p --\n", level, "", handler);
    891897}       
     898
     899int fd_sess_getcount(uint32_t *cnt)
     900{
     901        CHECK_PARAMS(cnt);
     902        CHECK_POSIX( pthread_mutex_lock( &exp_lock ) );
     903        *cnt = sess_cnt;
     904        CHECK_POSIX( pthread_mutex_unlock( &exp_lock ) );
     905        return 0;
     906}
Note: See TracChangeset for help on using the changeset viewer.