summaryrefslogtreecommitdiff
path: root/src/daemon/dlt_daemon_client.c
diff options
context:
space:
mode:
authorSaya Sugiura <ssugiura@jp.adit-jv.com>2019-05-23 13:56:33 +0900
committerSaya Sugiura <ssugiura@jp.adit-jv.com>2019-06-18 17:22:09 +0900
commit3580c5640c5578f508e93a8a851231b389d327cd (patch)
treeefe0dd5b737e0192ea541861452c0f3f0edde099 /src/daemon/dlt_daemon_client.c
parent341831da4da448392d62e48f1a4f419a18e3dca5 (diff)
downloadDLT-daemon-3580c5640c5578f508e93a8a851231b389d327cd.tar.gz
daemon: Remove bytes_sent
When it fails to send a log message to connected client, daemon tries to store the remaining partial message to internal ring buffer and send again later. When calculating the number of bytes which were sent to client, it had a bug which it keeps on incrementing instead of initializing the variable on every message, which never reached to the condition mentioned above and had a possibility to overflow and access invalid memory. On the other hand, daemon doesn't need to store the unsent partial message, as the socket to the client will be closed on failure and the sent partial message will be dropped anyways. This commit removes the lines where the daemon tries to store the partial message to ring buffer. With this, variable bytes_sent is now removed. Related commit: 2262f8b Made socket send reliable Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
Diffstat (limited to 'src/daemon/dlt_daemon_client.c')
-rw-r--r--src/daemon/dlt_daemon_client.c28
1 files changed, 0 insertions, 28 deletions
diff --git a/src/daemon/dlt_daemon_client.c b/src/daemon/dlt_daemon_client.c
index 55afd7c..d8062d5 100644
--- a/src/daemon/dlt_daemon_client.c
+++ b/src/daemon/dlt_daemon_client.c
@@ -113,7 +113,6 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon,
DltConnection *temp = NULL;
int type_mask =
(DLT_CON_MASK_CLIENT_MSG_TCP | DLT_CON_MASK_CLIENT_MSG_SERIAL);
- uint8_t *tmp_buffer = NULL;
if ((daemon == NULL) || (daemon_local == NULL)) {
dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
@@ -142,33 +141,6 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon,
if ((ret != DLT_DAEMON_ERROR_OK) &&
(DLT_CONNECTION_CLIENT_MSG_TCP == temp->type)) {
- if (daemon->state != DLT_DAEMON_STATE_BUFFER_FULL) {
- if (temp->receiver->bytes_sent < (size1 + size2)) {
- tmp_buffer = (uint8_t *)calloc(size1 + size2, sizeof(uint8_t));
-
- if (tmp_buffer == NULL) {
- dlt_vlog(LOG_ERR, "%s: Memory allocation failed.\n", __func__);
- return 0;
- }
-
- memcpy(tmp_buffer, data1, size1);
- memcpy(tmp_buffer + size1, data2, size2);
- DLT_DAEMON_SEM_LOCK();
-
- /* Store message in history buffer */
- if (dlt_buffer_push3(&(daemon->client_ringbuffer),
- tmp_buffer + temp->receiver->bytes_sent,
- (size1 + size2 - temp->receiver->bytes_sent),
- 0, 0, 0, 0) < DLT_RETURN_OK) {
- dlt_vlog(LOG_DEBUG, "%s: Buffer is full! Message discarded.\n", __func__);
- dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_BUFFER_FULL);
- }
-
- free(tmp_buffer);
- DLT_DAEMON_SEM_FREE();
- }
- }
-
dlt_daemon_close_socket(temp->receiver->fd,
daemon,
daemon_local,