diff options
author | Bui Nguyen Quoc Thanh <Thanh.BuiNguyenQuoc@vn.bosch.com> | 2020-03-03 10:16:25 +0700 |
---|---|---|
committer | Saya Sugiura <39760799+ssugiura@users.noreply.github.com> | 2020-07-06 10:04:07 +0900 |
commit | fbe9c0c0ee1b134ac335392ff18d239d69ab50c7 (patch) | |
tree | cd3412dd10b9623b3eda9a1f5e774a2b1bc2f603 | |
parent | d46840c9cd0e52dd7d133bbd64805fb9b8aa2aac (diff) | |
download | DLT-daemon-fbe9c0c0ee1b134ac335392ff18d239d69ab50c7.tar.gz |
daemon: Avoid spamming message buffer overflow
- In existing implementation, control message "message_buffer_overflow"
is sent for every incoming message which is dropped since buffer is full.
So UDP and logstorage will receive a lot of these messages.
That could be considered as unnecessary.
- In order to reduce the useless effort to send "message_buffer_overflow"
for every missing message, daemon will only send it out
right after buffer is full or right after real client is connected.
Signed-off-by: Bui Nguyen Quoc Thanh <Thanh.BuiNguyenQuoc@vn.bosch.com>
-rw-r--r-- | src/daemon/dlt-daemon.c | 27 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_client.c | 2 |
2 files changed, 9 insertions, 20 deletions
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index aff33e6..4b686de 100644 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -1679,25 +1679,14 @@ int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, cha /* Sending data... */ { - /* check if overflow occurred */ - if (daemon->overflow_counter) { - if (dlt_daemon_send_message_overflow(daemon, daemon_local, verbose) == 0) { - dlt_vlog(LOG_WARNING, "%u messages discarded!\n", - daemon->overflow_counter); - daemon->overflow_counter = 0; - } - } - - /* look if TCP connection to client is available */ - if ((daemon->mode == DLT_USER_MODE_EXTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH)) - - if ((ret = - dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local, msg.headerbuffer, - sizeof(DltStorageHeader), msg.headerbuffer + sizeof(DltStorageHeader), - msg.headersize - sizeof(DltStorageHeader), - msg.databuffer, msg.datasize, verbose))) - if (ret == DLT_DAEMON_ERROR_BUFFER_FULL) - daemon->overflow_counter++; + ret = dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL, daemon,daemon_local, + msg.headerbuffer, sizeof(DltStorageHeader), + msg.headerbuffer + sizeof(DltStorageHeader), + msg.headersize - sizeof(DltStorageHeader), + msg.databuffer, msg.datasize, verbose); + + if (ret == DLT_DAEMON_ERROR_BUFFER_FULL) + daemon->overflow_counter++; } free(msg.databuffer); diff --git a/src/daemon/dlt_daemon_client.c b/src/daemon/dlt_daemon_client.c index 3d90a47..c47c808 100644 --- a/src/daemon/dlt_daemon_client.c +++ b/src/daemon/dlt_daemon_client.c @@ -362,7 +362,7 @@ int dlt_daemon_client_send_message_to_all_client(DltDaemon *daemon, } /* check if overflow occurred */ - if (daemon->overflow_counter) { + 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", |