From 30d372cd4b3dd2ed24456c49a6f69ecdc9b42f0e Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Tue, 31 Jan 2017 12:24:30 +0100 Subject: [PATCH] websocket: option to avoid repetitive logs each 1 sec during pinging - few debug messages are printed each second while fetching the list of active connections for pining, making the log full while troubleshooting --- src/modules/websocket/websocket.c | 3 +++ src/modules/websocket/ws_conn.c | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/modules/websocket/websocket.c b/src/modules/websocket/websocket.c index 826c540027d..146666787a5 100644 --- a/src/modules/websocket/websocket.c +++ b/src/modules/websocket/websocket.c @@ -67,6 +67,8 @@ static int ws_keepalive_timeout = DEFAULT_KEEPALIVE_TIMEOUT; #define DEFAULT_KEEPALIVE_PROCESSES 1 static int ws_keepalive_processes = DEFAULT_KEEPALIVE_PROCESSES; +int ws_verbose_list = 0; + static cmd_export_t cmds[] = { /* ws_frame.c */ { "ws_close", (cmd_function) ws_close, @@ -101,6 +103,7 @@ static param_export_t params[] = { { "keepalive_interval", INT_PARAM, &ws_keepalive_interval }, { "keepalive_processes", INT_PARAM, &ws_keepalive_processes }, + { "verbose_list", PARAM_INT, &ws_verbose_list }, { 0, 0, 0 } }; diff --git a/src/modules/websocket/ws_conn.c b/src/modules/websocket/ws_conn.c index 4abe960a55c..900847b8e0c 100644 --- a/src/modules/websocket/ws_conn.c +++ b/src/modules/websocket/ws_conn.c @@ -36,6 +36,8 @@ /* Maximum number of connections to display when using the ws.dump command */ #define MAX_WS_CONNS_DUMP 50 +extern int ws_verbose_list; + ws_connection_t **wsconn_id_hash = NULL; #define wsconn_listadd tcpconn_listadd #define wsconn_listrm tcpconn_listrm @@ -454,7 +456,7 @@ ws_connection_t **wsconn_get_list(void) size_t list_len = 0; size_t i = 0; - LM_DBG("wsconn_get_list\n"); + if(ws_verbose_list) LM_DBG("wsconn get list - starting\n"); WSCONN_LOCK; @@ -462,7 +464,8 @@ ws_connection_t **wsconn_get_list(void) wsc = wsconn_used_list->head; while (wsc) { - LM_DBG("counter wsc [%p] prev => [%p] next => [%p]\n", wsc, wsc->used_prev, wsc->used_next); + if(ws_verbose_list) LM_DBG("counter wsc [%p] prev => [%p] next => [%p]\n", + wsc, wsc->used_prev, wsc->used_next); list_len++; wsc = wsc->used_next; } @@ -489,7 +492,7 @@ ws_connection_t **wsconn_get_list(void) list[i] = wsc; wsconn_ref(wsc); - LM_DBG("wsc [%p] id [%d] ref++\n", wsc, wsc->id); + if(ws_verbose_list) LM_DBG("wsc [%p] id [%d] ref++\n", wsc, wsc->id); wsc = wsc->used_next; } @@ -498,7 +501,8 @@ ws_connection_t **wsconn_get_list(void) end: WSCONN_UNLOCK; - LM_DBG("wsconn_get_list returns list [%p] with [%d] members\n", list, (int)list_len); + if(ws_verbose_list) LM_DBG("wsconn_get_list returns list [%p]" + " with [%d] members\n", list, (int)list_len); return list; }