Navigation


Changeset 778:003df4a9ade2 in freeDiameter for libfdproto


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

Location:
libfdproto
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libfdproto/dictionary.c

    r770 r778  
    18121812}
    18131813
     1814
     1815int fd_dict_delete(struct dict_object * obj)
     1816{
     1817        int i;
     1818        struct dictionary * dict;
     1819        int ret=0;
     1820       
     1821        /* check params */
     1822        CHECK_PARAMS( verify_object(obj) && obj->dico);
     1823        dict = obj->dico;
     1824
     1825        /* Lock the dictionary for change */
     1826        CHECK_POSIX(  pthread_rwlock_wrlock(&dict->dict_lock)  );
     1827       
     1828        /* check the object is not sentinel for another list */
     1829        for (i=0; i<NB_LISTS_PER_OBJ; i++) {
     1830                if (!_OBINFO(obj).haslist[i] && !(FD_IS_LIST_EMPTY(&obj->list[i]))) {
     1831                        /* There are children, this is not good */
     1832                        ret = EINVAL;
     1833                        TRACE_DEBUG (FULL, "Cannot delete object, list %d not empty:", i);
     1834                        #if 0
     1835                        dump_list(&obj->list[i], 0,0,0);
     1836                        #endif
     1837                        break;
     1838                }
     1839        }
     1840       
     1841        /* ok, now destroy the object */
     1842        if (!ret)
     1843                destroy_object(obj);
     1844       
     1845        /* Unlock */
     1846        CHECK_POSIX(  pthread_rwlock_unlock(&dict->dict_lock)  );
     1847       
     1848        return ret;
     1849}
     1850
     1851
    18141852int fd_dict_search ( struct dictionary * dict, enum dict_object_type type, int criteria, void * what, struct dict_object **result, int retval )
    18151853{
  • 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.