diff options
author | Manikandan C <mchockalingam@de.adit-jv.com> | 2018-11-28 11:01:44 +0100 |
---|---|---|
committer | Christoph Lipka <clipka@users.noreply.github.com> | 2018-12-21 10:16:46 +0100 |
commit | 2262f8b3406ac903a37f96a63c6250de215d1866 (patch) | |
tree | a5fcd778ae75d9ac1cd04202324a00ab50d3c7bd /src/daemon/dlt_daemon_client.c | |
parent | 037d33d0c1bc83ca79812340ea9120d13fd1c705 (diff) | |
download | DLT-daemon-2262f8b3406ac903a37f96a63c6250de215d1866.tar.gz |
Made socket send reliable
Made TCP socket send reliable by storing the unsent/partial message
in the ring buffer. This will avoid the corrupted messages/Gaps in
Viewer side
Signed-off-by: ManikandanC <Manikandan.Chockalingam@in.bosch.com>
Diffstat (limited to 'src/daemon/dlt_daemon_client.c')
-rw-r--r-- | src/daemon/dlt_daemon_client.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/src/daemon/dlt_daemon_client.c b/src/daemon/dlt_daemon_client.c index bd3233f..120d2af 100644 --- a/src/daemon/dlt_daemon_client.c +++ b/src/daemon/dlt_daemon_client.c @@ -114,14 +114,11 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon, int type_mask = (DLT_CON_MASK_CLIENT_MSG_TCP | DLT_CON_MASK_CLIENT_MSG_SERIAL); char local_str[DLT_DAEMON_TEXTBUFSIZE]; + uint8_t *tmp_buffer = NULL; if ((daemon == NULL) || (daemon_local == NULL)) { - snprintf(local_str, - DLT_DAEMON_TEXTBUFSIZE, - "%s: Invalid parameters\n", - __func__); - dlt_log(LOG_ERR, local_str); + dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__); return 0; } @@ -146,9 +143,33 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon, daemon->sendserialheader); DLT_DAEMON_SEM_FREE(); - if((ret != DLT_DAEMON_ERROR_OK) && - DLT_CONNECTION_CLIENT_MSG_TCP == temp->type) + 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)); + 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, |