Module: sip-router
Branch: master
Commit: a9e555e6e41271e015c47d29ba85276673d3b7b6
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a9e555e…
Author: Andrew Mortensen <admorten(a)isc.upenn.edu>
Committer: Andrew Mortensen <admorten(a)isc.upenn.edu>
Date: Mon Apr 8 15:01:41 2013 -0400
modules/sca: reduce verbosity of RPC sca.all_subscriptions output
- accommodate more subscriptions without hitting kamcmd buffer limits.
---
modules/sca/sca_rpc.c | 38 ++++++++++++++++++++++++++++++++------
1 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/modules/sca/sca_rpc.c b/modules/sca/sca_rpc.c
index f0ee345..58f5ae5 100644
--- a/modules/sca/sca_rpc.c
+++ b/modules/sca/sca_rpc.c
@@ -23,6 +23,9 @@
*/
#include "sca_common.h"
+#include <sys/types.h>
+#include <time.h>
+
#include "sca_rpc.h"
#include "sca.h"
@@ -82,7 +85,9 @@ sca_rpc_show_all_subscriptions( rpc_t *rpc, void *ctx )
sca_hash_table *ht;
sca_hash_entry *ent;
sca_subscription *sub;
+ sip_uri_t aor_uri, sub_uri;
str sub_state = STR_NULL;
+ time_t now;
int i;
int rc = 0;
@@ -91,6 +96,8 @@ sca_rpc_show_all_subscriptions( rpc_t *rpc, void *ctx )
return;
}
+ now = time( NULL );
+
for ( i = 0; i < ht->size; i++ ) {
sca_hash_table_lock_index( ht, i );
@@ -98,12 +105,31 @@ sca_rpc_show_all_subscriptions( rpc_t *rpc, void *ctx )
sub = (sca_subscription *)ent->value;
sca_subscription_state_to_str( sub->state, &sub_state );
- rc = rpc->printf( ctx, "%d: %.*s %.*s %s %d %.*s", i,
- STR_FMT( &sub->target_aor ),
- STR_FMT( &sub->subscriber ),
- sca_event_name_from_type( sub->event ),
- sub->expires,
- STR_FMT( &sub_state ));
+ rc = parse_uri( sub->target_aor.s, sub->target_aor.len, &aor_uri );
+ if ( rc >= 0 ) {
+ rc = parse_uri( sub->subscriber.s, sub->subscriber.len,
+ &sub_uri );
+ }
+ if ( rc >= 0 ) {
+ rc = rpc->printf( ctx, "%.*s %.*s%s%.*s %s %ld %.*s",
+ STR_FMT( &aor_uri.user ),
+ STR_FMT( &sub_uri.host ),
+ (sub_uri.port.len ? ":" : "" ),
+ STR_FMT( &sub_uri.port ),
+ sca_event_name_from_type( sub->event ),
+ (long)(sub->expires - now),
+ STR_FMT( &sub_state ));
+ } else {
+ LM_ERR( "sca_rpc_show_all_subscriptions: parse_uri %.*s "
+ "failed, dumping unparsed info",
+ STR_FMT( &sub->target_aor ));
+ rc = rpc->printf( ctx, "%.*s %.*s %s %ld %.*s",
+ STR_FMT( &sub->target_aor ),
+ STR_FMT( &sub->subscriber ),
+ sca_event_name_from_type( sub->event ),
+ (long)sub->expires,
+ STR_FMT( &sub_state ));
+ }
if ( rc < 0 ) {
/* make sure we unlock below */