From c0632bb3950869b6e77bd3a84486ada7f6b1f33d Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Fri, 23 Nov 2007 03:47:50 +0000 Subject: Ticket #424: Added API to retrieve number of transactions and dialogs (thanks Sergey Bakulin) git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1594 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/include/pjsip/sip_transaction.h | 8 ++++++++ pjsip/include/pjsip/sip_ua_layer.h | 13 +++++++++++++ pjsip/src/pjsip/sip_transaction.c | 19 +++++++++++++++++++ pjsip/src/pjsip/sip_ua_layer.c | 18 ++++++++++++++++++ 4 files changed, 58 insertions(+) (limited to 'pjsip') diff --git a/pjsip/include/pjsip/sip_transaction.h b/pjsip/include/pjsip/sip_transaction.h index f47005e3..9550c32a 100644 --- a/pjsip/include/pjsip/sip_transaction.h +++ b/pjsip/include/pjsip/sip_transaction.h @@ -158,6 +158,14 @@ PJ_DECL(pjsip_module*) pjsip_tsx_layer_instance(void); */ PJ_DECL(pj_status_t) pjsip_tsx_layer_destroy(void); +/** + * Retrieve the current number of transactions currently registered + * in the hash table. + * + * @return Number of transactions. + */ +PJ_DECL(unsigned) pjsip_tsx_layer_get_tsx_count(void); + /** * Find a transaction with the specified key. The transaction key normally * is created by calling #pjsip_tsx_create_key() from an incoming message. diff --git a/pjsip/include/pjsip/sip_ua_layer.h b/pjsip/include/pjsip/sip_ua_layer.h index 67d3e644..19852777 100644 --- a/pjsip/include/pjsip/sip_ua_layer.h +++ b/pjsip/include/pjsip/sip_ua_layer.h @@ -80,6 +80,19 @@ PJ_DECL(pj_status_t) pjsip_ua_init_module(pjsip_endpoint *endpt, PJ_DECL(pjsip_user_agent*) pjsip_ua_instance(void); +/** + * Retrieve the current number of dialog-set currently registered + * in the hash table. Note that dialog-set is different than dialog + * when the request forks. In this case, all dialogs created from + * the original request will belong to the same dialog set. When + * no forking occurs, the number of dialog sets will be equal to + * the number of dialogs. + * + * @return Number of dialog sets. + */ +PJ_DECL(pj_uint32_t) pjsip_ua_get_dlg_set_count(void); + + /** * Find a dialog with the specified Call-ID and tags properties. This * function may optionally lock the matching dialog instance before diff --git a/pjsip/src/pjsip/sip_transaction.c b/pjsip/src/pjsip/sip_transaction.c index dbbccf60..61f85cef 100644 --- a/pjsip/src/pjsip/sip_transaction.c +++ b/pjsip/src/pjsip/sip_transaction.c @@ -580,6 +580,25 @@ static void mod_tsx_layer_unregister_tsx( pjsip_transaction *tsx) } +/* + * Retrieve the current number of transactions currently registered in + * the hash table. + */ +PJ_DEF(unsigned) pjsip_tsx_layer_get_tsx_count(void) +{ + unsigned count; + + /* Are we registered? */ + PJ_ASSERT_RETURN(mod_tsx_layer.endpt!=NULL, 0); + + pj_mutex_lock(mod_tsx_layer.mutex); + count = pj_hash_count(mod_tsx_layer.htable); + pj_mutex_unlock(mod_tsx_layer.mutex); + + return count; +} + + /* * Find a transaction. */ diff --git a/pjsip/src/pjsip/sip_ua_layer.c b/pjsip/src/pjsip/sip_ua_layer.c index c345b011..19cccbd0 100644 --- a/pjsip/src/pjsip/sip_ua_layer.c +++ b/pjsip/src/pjsip/sip_ua_layer.c @@ -412,6 +412,24 @@ PJ_DEF(pjsip_dialog*) pjsip_tsx_get_dlg( pjsip_transaction *tsx ) } +/* + * Retrieve the current number of dialog-set currently registered + * in the hash table. + */ +PJ_DEF(unsigned) pjsip_ua_get_dlg_set_count(void) +{ + unsigned count; + + PJ_ASSERT_RETURN(mod_ua.endpt, 0); + + pj_mutex_lock(mod_ua.mutex); + count = pj_hash_count(mod_ua.dlg_table); + pj_mutex_unlock(mod_ua.mutex); + + return count; +} + + /* * Find a dialog. */ -- cgit v1.2.3