diff options
Diffstat (limited to 'src/daemon')
-rwxr-xr-x | src/daemon/dlt-daemon.c | 14 | ||||
-rwxr-xr-x | src/daemon/dlt_daemon_common.c | 65 | ||||
-rwxr-xr-x | src/daemon/dlt_daemon_common.h | 19 |
3 files changed, 98 insertions, 0 deletions
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index 0e52d3c..4ab628f 100755 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -1016,6 +1016,10 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon, DltDaemonLocal *daemon_ { /* send ringbuffer done in old implementation */ /* nothing to do with shared memory */ + + /* send new log state to all applications */ + daemon->state = 1; + dlt_daemon_user_send_all_log_state(daemon,verbose); } return 0; @@ -1043,6 +1047,13 @@ int dlt_daemon_process_client_messages(DltDaemon *daemon, DltDaemonLocal *daemon daemon_local->client_connections--; } + if(daemon_local->client_connections==0) + { + /* send new log state to all applications */ + daemon->state = 0; + dlt_daemon_user_send_all_log_state(daemon,verbose); + } + if (daemon_local->flags.vflag) { sprintf(str, "Connection to client lost, #connections: %d\n",daemon_local->client_connections); @@ -1389,6 +1400,9 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon, DltD application=dlt_daemon_application_add(daemon,usercontext->apid,usercontext->pid,description,verbose); + /* send log state to new application */ + dlt_daemon_user_send_log_state(daemon,application,verbose); + /* keep not read data in buffer */ if (dlt_receiver_remove(&(daemon_local->receiver),sizeof(DltUserHeader)+sizeof(DltUserControlMsgRegisterApplication)+len)==-1) { diff --git a/src/daemon/dlt_daemon_common.c b/src/daemon/dlt_daemon_common.c index e10b20d..dbb1e7a 100755 --- a/src/daemon/dlt_daemon_common.c +++ b/src/daemon/dlt_daemon_common.c @@ -969,6 +969,42 @@ int dlt_daemon_user_send_log_level(DltDaemon *daemon,DltDaemonContext *context,i return ((ret==DLT_RETURN_OK)?0:-1); } +int dlt_daemon_user_send_log_state(DltDaemon *daemon,DltDaemonApplication *app,int verbose) +{ + DltUserHeader userheader; + DltUserControlMsgLogState logstate; + DltReturnValue ret; + + PRINT_FUNCTION_VERBOSE(verbose); + + if ((daemon==0) || (app==0)) + { + return -1; + } + + if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_LOG_STATE)==-1) + { + return -1; + } + + logstate.log_state = daemon->state; + + /* log to FIFO */ + ret = dlt_user_log_out2(app->user_handle, &(userheader), sizeof(DltUserHeader), &(logstate), sizeof(DltUserControlMsgLogState)); + + if (ret!=DLT_RETURN_OK) + { + if (errno==EPIPE) + { + /* Close connection */ + close(app->user_handle); + app->user_handle=0; + } + } + + return ((ret==DLT_RETURN_OK)?0:-1); +} + int dlt_daemon_control_process_control(int sock, DltDaemon *daemon, DltMessage *msg, int verbose) { uint32_t id,id_tmp=0; @@ -2179,6 +2215,35 @@ void dlt_daemon_user_send_default_update(DltDaemon *daemon, int verbose) } } +void dlt_daemon_user_send_all_log_state(DltDaemon *daemon, int verbose) +{ + int32_t count; + DltDaemonApplication *app; + + PRINT_FUNCTION_VERBOSE(verbose); + + if (daemon==0) + { + return; + } + + for (count=0;count<daemon->num_applications; count ++) + { + app = &(daemon->applications[count]); + + if (app) + { + if (app->user_handle!=0) + { + if (dlt_daemon_user_send_log_state(daemon, app, verbose)==-1) + { + return; + } + } + } + } +} + void dlt_daemon_control_message_time(int sock, DltDaemon *daemon, int verbose) { DltMessage msg; diff --git a/src/daemon/dlt_daemon_common.h b/src/daemon/dlt_daemon_common.h index 1fd3d2e..2bdb637 100755 --- a/src/daemon/dlt_daemon_common.h +++ b/src/daemon/dlt_daemon_common.h @@ -153,6 +153,7 @@ typedef struct char runtime_context_cfg[256]; /**< Path and filename of persistent context configuration */
char runtime_configuration[256]; /**< Path and filename of persistent configuration */
DltUserLogMode mode; /**< Mode used for tracing: off, external, internal, both */
+ char state; /**< state for tracing: 0 = no client connected, 1 = client connected */
} DltDaemon;
/**
@@ -302,6 +303,16 @@ int dlt_daemon_configuration_save(DltDaemon *daemon,const char *filename, int ve * @return negative value if there was an error
*/
int dlt_daemon_user_send_log_level(DltDaemon *daemon,DltDaemonContext *context, int verbose);
+
+/**
+ * Send user message DLT_USER_MESSAGE_LOG_STATE to user application
+ * @param daemon pointer to dlt daemon structure
+ * @param app pointer to application for response
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+int dlt_daemon_user_send_log_state(DltDaemon *daemon,DltDaemonApplication *app,int verbose);
+
/**
* Send user messages to all user applications using default context, or trace status
* to update those values
@@ -311,6 +322,14 @@ int dlt_daemon_user_send_log_level(DltDaemon *daemon,DltDaemonContext *context, void dlt_daemon_user_send_default_update(DltDaemon *daemon, int verbose);
/**
+ * Send user messages to all user applications the log status
+ * everytime the client is connected or disconnected.
+ * @param daemon pointer to dlt daemon structure
+ * @param verbose if set to true verbose information is printed out.
+ */
+void dlt_daemon_user_send_all_log_state(DltDaemon *daemon, int verbose);
+
+/**
* Process received control message from dlt client
* @param sock connection handle used for sending response
* @param daemon pointer to dlt daemon structure
|