Module: sip-router
Branch: pd/websocket
Commit: c270ac0e54ada9cc2599b21f8c87b5a0704093af
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c270ac0…
Author: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Date: Sun Jun 24 00:40:24 2012 +0100
modules/websocket: improvements to ws.dump MI command
---
modules/websocket/ws_conn.c | 32 ++++++++++++++++++++++++++------
1 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/modules/websocket/ws_conn.c b/modules/websocket/ws_conn.c
index 664750f..e2795a0 100644
--- a/modules/websocket/ws_conn.c
+++ b/modules/websocket/ws_conn.c
@@ -369,25 +369,27 @@ struct mi_root *ws_mi_dump(struct mi_root *cmd, void *param)
{
if (node->value.s == NULL || node->value.len == 0)
{
- LM_ERR("empty display order parameter\n");
+ LM_WARN("empty display order parameter\n");
return init_mi_tree(400, str_status_empty_param.s,
str_status_empty_param.len);
}
strlower(&node->value);
- if (strncmp(node->value.s, "id", 2) == 0)
+ if (strncmp(node->value.s, "id_hash", 7) == 0)
order = 0;
- else if (strncmp(node->value.s, "used", 4) == 0)
+ else if (strncmp(node->value.s, "used_desc", 9) == 0)
order = 1;
+ else if (strncmp(node->value.s, "used_asc", 8) == 0)
+ order = 2;
else
{
- LM_ERR("bad display order parameter\n");
+ LM_WARN("bad display order parameter\n");
return init_mi_tree(400, str_status_bad_param.s,
str_status_bad_param.len);
}
if (node->next != NULL)
{
- LM_ERR("too many parameters\n");
+ LM_WARN("too many parameters\n");
return init_mi_tree(400, str_status_too_many_params.s,
str_status_too_many_params.len);
}
@@ -419,7 +421,7 @@ struct mi_root *ws_mi_dump(struct mi_root *cmd, void *param)
break;
}
}
- else
+ else if (order == 1)
{
wsc = wsconn_used_list->head;
while (wsc)
@@ -437,6 +439,24 @@ struct mi_root *ws_mi_dump(struct mi_root *cmd, void *param)
wsc = wsc->used_next;
}
}
+ else
+ {
+ wsc = wsconn_used_list->tail;
+ while (wsc)
+ {
+ if ((found = add_node(rpl_tree, wsc)) < 0)
+ return 0;
+
+ connections += found;
+ if (connections >= MAX_WS_CONNS_DUMP)
+ {
+ truncated = 1;
+ break;
+ }
+
+ wsc = wsc->used_prev;
+ }
+ }
WSCONN_UNLOCK;
if (addf_mi_node_child(&rpl_tree->node, 0, 0, 0,