From bfa7026b355db32d91374997cc86b56fedc3e861 Mon Sep 17 00:00:00 2001 From: Yusuke Sato Date: Fri, 11 May 2018 20:10:56 +0900 Subject: dlt-daemon: Output current number of connections as default In previous, number of connections was output only if verbose mode in dlt.conf was enabled. This information is basically useful and is not output frequently. Therefore number of connections information is made to output as default when new connection is established or the connection is lost. Signed-off-by: Yusuke Sato --- src/daemon/dlt-daemon.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index 016b2c9..e3475d4 100644 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -1574,6 +1574,7 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon, struct sockaddr cli; int in_sock = -1; + char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' }; PRINT_FUNCTION_VERBOSE(verbose); @@ -1623,15 +1624,6 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon, return -1; } - if (daemon_local->flags.vflag) - { - snprintf(str, - DLT_DAEMON_TEXTBUFSIZE, - "New connection to client established, #connections: %d\n", - daemon_local->client_connections); - dlt_log(LOG_INFO, str); - } - // send connection info about connected dlt_daemon_control_message_connection_info(in_sock, daemon, @@ -1660,6 +1652,14 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon, } } + snprintf(local_str, + DLT_DAEMON_TEXTBUFSIZE, + "New client connection #%d established, Total Clients : %d\n", + in_sock, + daemon_local->client_connections); + dlt_log(LOG_DEBUG, local_str); + dlt_daemon_log_internal(daemon, daemon_local, local_str, daemon_local->flags.vflag); + if (daemon_local->client_connections == 1) { if (daemon_local->flags.vflag) @@ -3419,6 +3419,8 @@ int create_timer_fd(DltDaemonLocal *daemon_local, /* Close connection function */ int dlt_daemon_close_socket(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose) { + char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' }; + PRINT_FUNCTION_VERBOSE(verbose); if((daemon_local == NULL)|| (daemon == NULL)) @@ -3446,14 +3448,15 @@ int dlt_daemon_close_socket(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_ dlt_daemon_change_state(daemon,DLT_DAEMON_STATE_BUFFER); } - if (daemon_local->flags.vflag) - { - snprintf(str,DLT_DAEMON_TEXTBUFSIZE, "Connection to client lost, #connections: %d\n",daemon_local->client_connections); - dlt_log(LOG_INFO, str); - } - dlt_daemon_control_message_connection_info(DLT_DAEMON_SEND_TO_ALL,daemon,daemon_local,DLT_CONNECTION_STATUS_DISCONNECTED,"",verbose); + snprintf(local_str, DLT_DAEMON_TEXTBUFSIZE, + "Client connection #%d closed. Total Clients : %d\n", + sock, + daemon_local->client_connections); + dlt_log(LOG_DEBUG, local_str); + dlt_daemon_log_internal(daemon, daemon_local, local_str, daemon_local->flags.vflag); + return 0; } -- cgit v1.2.1