From 3c89cdf9ca2aae9e0a602997ed0245692ddf976a Mon Sep 17 00:00:00 2001 From: Sascha Philipp Date: Mon, 6 Oct 2014 13:07:48 +0200 Subject: Change daemon state handling to have all traces in online trace even when offline trace is active Change-Id: Ic212c4956582b18e05739d593bf5c792d60d9c00 Signed-off-by: Sascha Philipp --- src/daemon/dlt-daemon.c | 12 ++++++++---- src/daemon/dlt_daemon_client.c | 5 ++++- src/daemon/dlt_daemon_common.c | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index 5e56302..6c44da5 100644 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -485,8 +485,10 @@ int main(int argc, char* argv[]) create_timer_fd(&daemon_local, 60, 60, &daemon_local.timer_sixty_s, "ECU version"); } - if(daemon_local.flags.yvalue[0] || - ((daemon_local.flags.offlineTraceDirectory[0]) && ((daemon.mode == DLT_USER_MODE_INTERNAL) || (daemon.mode == DLT_USER_MODE_BOTH)))) + // For offline tracing we still can use the same states + // as for socket sending. Using this trick we see the traces + // In the offline trace AND in the socket stream. + if(daemon_local.flags.yvalue[0]) dlt_daemon_change_state(&daemon,DLT_DAEMON_STATE_SEND_DIRECT); else dlt_daemon_change_state(&daemon,DLT_DAEMON_STATE_BUFFER); @@ -2677,8 +2679,10 @@ int dlt_daemon_close_socket(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_ daemon->connectionState = 0; dlt_daemon_user_send_all_log_state(daemon,verbose); - if((daemon_local->flags.yvalue[0] == 0) && - ((daemon_local->flags.offlineTraceDirectory[0] == 0) || (daemon->mode == DLT_USER_MODE_EXTERNAL))) + // For offline tracing we still can use the same states + // as for socket sending. Using this trick we see the traces + // In the offline trace AND in the socket stream. + if(daemon_local->flags.yvalue[0] == 0) dlt_daemon_change_state(daemon,DLT_DAEMON_STATE_BUFFER); } diff --git a/src/daemon/dlt_daemon_client.c b/src/daemon/dlt_daemon_client.c index fe75d90..00ad5b9 100644 --- a/src/daemon/dlt_daemon_client.c +++ b/src/daemon/dlt_daemon_client.c @@ -96,7 +96,10 @@ int dlt_daemon_client_send(int sock,DltDaemon *daemon,DltDaemonLocal *daemon_loc } /* write message to offline trace */ - if ((sock!=DLT_DAEMON_SEND_FORCE) && (daemon->state == DLT_DAEMON_STATE_SEND_DIRECT) && !control) + // In the SEND_BUFFER state we must skip offline tracing because the offline traces + // are going without buffering directly to the offline trace. Thus we have to filter out + // the traces that are coming from the buffer. + if ((sock!=DLT_DAEMON_SEND_FORCE) && (daemon->state != DLT_DAEMON_STATE_SEND_BUFFER)) { if(((daemon->mode == DLT_USER_MODE_INTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH)) && daemon_local->flags.offlineTraceDirectory[0]) diff --git a/src/daemon/dlt_daemon_common.c b/src/daemon/dlt_daemon_common.c index 464bd28..ce6af70 100644 --- a/src/daemon/dlt_daemon_common.c +++ b/src/daemon/dlt_daemon_common.c @@ -1296,7 +1296,7 @@ void dlt_daemon_change_state(DltDaemon *daemon, DltDaemonState newState) daemon->state = DLT_DAEMON_STATE_INIT; break; case DLT_DAEMON_STATE_BUFFER: - dlt_log(LOG_INFO,"Switched to buffer state.\n"); + dlt_log(LOG_INFO,"Switched to buffer state for socket connections.\n"); daemon->state = DLT_DAEMON_STATE_BUFFER; break; case DLT_DAEMON_STATE_BUFFER_FULL: @@ -1304,7 +1304,7 @@ void dlt_daemon_change_state(DltDaemon *daemon, DltDaemonState newState) daemon->state = DLT_DAEMON_STATE_BUFFER_FULL; break; case DLT_DAEMON_STATE_SEND_BUFFER: - dlt_log(LOG_INFO,"Switched to send buffer state.\n"); + dlt_log(LOG_INFO,"Switched to send buffer state for socket connections.\n"); daemon->state = DLT_DAEMON_STATE_SEND_BUFFER; break; case DLT_DAEMON_STATE_SEND_DIRECT: -- cgit v1.2.1