diff options
Diffstat (limited to 'src/daemon/dlt_daemon_client.c')
-rw-r--r-- | src/daemon/dlt_daemon_client.c | 62 |
1 files changed, 29 insertions, 33 deletions
diff --git a/src/daemon/dlt_daemon_client.c b/src/daemon/dlt_daemon_client.c index 3560910..9450e77 100644 --- a/src/daemon/dlt_daemon_client.c +++ b/src/daemon/dlt_daemon_client.c @@ -187,7 +187,7 @@ int dlt_daemon_client_send(int sock, if ((ret = dlt_daemon_serial_send(sock, data1, size1, data2, size2, daemon->sendserialheader))) { DLT_DAEMON_SEM_FREE(); - dlt_log(LOG_WARNING, "dlt_daemon_client_send: serial send dlt message failed\n"); + dlt_vlog(LOG_WARNING, "%s: serial send dlt message failed\n", __func__); return ret; } @@ -198,7 +198,7 @@ int dlt_daemon_client_send(int sock, if ((ret = dlt_daemon_socket_send(sock, data1, size1, data2, size2, daemon->sendserialheader))) { DLT_DAEMON_SEM_FREE(); - dlt_log(LOG_WARNING, "dlt_daemon_client_send: socket send dlt message failed\n"); + dlt_vlog(LOG_WARNING, "%s: socket send dlt message failed\n", __func__); return ret; } @@ -220,7 +220,7 @@ int dlt_daemon_client_send(int sock, static int error_dlt_offline_trace_write_failed = 0; if (!error_dlt_offline_trace_write_failed) { - dlt_log(LOG_ERR, "dlt_daemon_client_send: dlt_offline_trace_write failed!\n"); + dlt_vlog(LOG_ERR, "%s: dlt_offline_trace_write failed!\n", __func__); error_dlt_offline_trace_write_failed = 1; } @@ -273,20 +273,31 @@ int dlt_daemon_client_send(int sock, if ((sock != DLT_DAEMON_SEND_FORCE) && ((daemon->state == DLT_DAEMON_STATE_BUFFER) || (daemon->state == DLT_DAEMON_STATE_SEND_BUFFER) || (daemon->state == DLT_DAEMON_STATE_BUFFER_FULL))) { - if (daemon->state == DLT_DAEMON_STATE_BUFFER_FULL) - return DLT_DAEMON_ERROR_BUFFER_FULL; + if (daemon->state != DLT_DAEMON_STATE_BUFFER_FULL) { + DLT_DAEMON_SEM_LOCK(); + /* Store message in history buffer */ + ret = dlt_buffer_push3(&(daemon->client_ringbuffer), data1, size1, data2, size2, 0, 0); + DLT_DAEMON_SEM_FREE(); - DLT_DAEMON_SEM_LOCK(); + if (ret < DLT_RETURN_OK) { + dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_BUFFER_FULL); + } + } + if (daemon->state == DLT_DAEMON_STATE_BUFFER_FULL) { + daemon->overflow_counter += 1; + if (daemon->overflow_counter == 1) + dlt_vlog(LOG_INFO, "%s: Buffer is full! Messages will be discarded.\n", __func__); - /* Store message in history buffer */ - if (dlt_buffer_push3(&(daemon->client_ringbuffer), data1, size1, data2, size2, 0, 0) < DLT_RETURN_OK) { - DLT_DAEMON_SEM_FREE(); - dlt_log(LOG_DEBUG, "dlt_daemon_client_send: Buffer is full! Message discarded.\n"); - dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_BUFFER_FULL); return DLT_DAEMON_ERROR_BUFFER_FULL; } - - DLT_DAEMON_SEM_FREE(); + } else { + if ((daemon->overflow_counter > 0) && + (daemon_local->client_connections > 0) && + (dlt_daemon_send_message_overflow(daemon, daemon_local, verbose) == DLT_DAEMON_ERROR_OK)) { + dlt_vlog(LOG_WARNING, "%s: %u messages discarded! Now able to send messages to the client.\n", + __func__, daemon->overflow_counter); + daemon->overflow_counter = 0; + } } return DLT_DAEMON_ERROR_OK; @@ -297,7 +308,6 @@ int dlt_daemon_client_send_message_to_all_client(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose) { - int ret = DLT_DAEMON_ERROR_OK; static char text[DLT_DAEMON_TEXTSIZE]; char * ecu_ptr = NULL; @@ -359,27 +369,13 @@ int dlt_daemon_client_send_message_to_all_client(DltDaemon *daemon, dlt_log(LOG_WARNING, "dlt_message_print_header() failed!\n"); } - /* check if overflow occurred */ - if (daemon->overflow_counter == 1) { - ret = dlt_daemon_send_message_overflow(daemon, daemon_local, verbose); - if (DLT_DAEMON_ERROR_OK == ret) { - dlt_vlog(LOG_WARNING, "%s: %u messages discarded! Now able to send messages to the client.\n", - __func__, daemon->overflow_counter); - daemon->overflow_counter = 0; - } - } - /* send message to client or write to log file */ - ret = dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local, - daemon_local->msg.headerbuffer, sizeof(DltStorageHeader), - daemon_local->msg.headerbuffer + sizeof(DltStorageHeader), - daemon_local->msg.headersize - sizeof(DltStorageHeader), - daemon_local->msg.databuffer, daemon_local->msg.datasize, verbose); - - if (ret == DLT_DAEMON_ERROR_BUFFER_FULL) - daemon->overflow_counter++; + return dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local, + daemon_local->msg.headerbuffer, sizeof(DltStorageHeader), + daemon_local->msg.headerbuffer + sizeof(DltStorageHeader), + daemon_local->msg.headersize - sizeof(DltStorageHeader), + daemon_local->msg.databuffer, daemon_local->msg.datasize, verbose); - return ret; } int dlt_daemon_client_send_control_message(int sock, |