Module: sip-router Branch: pd/websocket Commit: 76f15b97d60b0e1c2c22fabc6c7310b33ad80742 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=76f15b97...
Author: Peter Dunkley peter.dunkley@crocodile-rcs.com Committer: Peter Dunkley peter.dunkley@crocodile-rcs.com Date: Thu Jun 21 17:37:08 2012 +0100
modules/websocket: More tidying up
---
modules/websocket/ws_conn.c | 8 ++++---- modules/websocket/ws_mod.c | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/modules/websocket/ws_conn.c b/modules/websocket/ws_conn.c index 5f5dcf9..ba3dcc8 100644 --- a/modules/websocket/ws_conn.c +++ b/modules/websocket/ws_conn.c @@ -31,10 +31,10 @@ gen_lock_t *wsconn_lock = NULL;
char *wsconn_state_str[] = { - "CONNECTING", - "OPEN", - "CLOSING", - "CLOSED" + "CONNECTING", /* WS_S_CONNECTING */ + "OPEN", /* WS_S_OPEN */ + "CLOSING", /* WS_S_CLOSING */ + "CLOSED" /* WS_S_CLOSED */ };
static inline void _wsconn_rm(ws_connection_t *wsc); diff --git a/modules/websocket/ws_mod.c b/modules/websocket/ws_mod.c index 5f5c67b..46fc5d0 100644 --- a/modules/websocket/ws_mod.c +++ b/modules/websocket/ws_mod.c @@ -39,6 +39,9 @@
MODULE_VERSION
+/* Maximum number of connections to display when using the ws.dump MI command */ +#define MAX_WS_CONNS_DUMP 50 + extern gen_lock_t *tcpconn_lock; extern struct tcp_connection **tcpconn_id_hash;
@@ -197,7 +200,7 @@ static void destroy(void)
static struct mi_root *mi_dump(struct mi_root *cmd, void *param) { - int h, connections = 0, interval; + int h, connections = 0, truncated = 0, interval; char *src_proto, *dst_proto; char src_ip[IP6_MAX_STR_SIZE + 1], dst_ip[IP6_MAX_STR_SIZE + 1]; ws_connection_t *wsc; @@ -243,7 +246,11 @@ static struct mi_root *mi_dump(struct mi_root *cmd, void *param) interval) == 0) return 0;
- connections++; + if (++connections == MAX_WS_CONNS_DUMP) + { + truncated = 1; + break; + } }
wsc = wsc->next; @@ -252,8 +259,9 @@ static struct mi_root *mi_dump(struct mi_root *cmd, void *param) WSCONN_UNLOCK;
if (addf_mi_node_child(&rpl_tree->node, 0, 0, 0, - "%d WebSocket connection%s found", - connections, connections == 1 ? "" : "s") == 0) + "%d WebSocket connection%s found%s", + connections, connections == 1 ? "" : "s", + truncated == 1 ? "(truncated)" : "") == 0) return 0;
return rpl_tree;