summaryrefslogtreecommitdiff
path: root/src/daemon/dlt_daemon_connection.c
diff options
context:
space:
mode:
authorManikandan C <mchockalingam@de.adit-jv.com>2018-11-28 11:01:44 +0100
committerManikandan C <mchockalingam@de.adit-jv.com>2018-12-11 09:33:05 +0100
commitd082636cabdffff3f6c62b907918d9a8d8f0cf35 (patch)
tree962aac58e134be7285646fe3c1c15f893e032751 /src/daemon/dlt_daemon_connection.c
parent8c55a51cfb09f81ee23db7c380ede6a814fb3014 (diff)
downloadDLT-daemon-d082636cabdffff3f6c62b907918d9a8d8f0cf35.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_connection.c')
-rw-r--r--src/daemon/dlt_daemon_connection.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/daemon/dlt_daemon_connection.c b/src/daemon/dlt_daemon_connection.c
index 4287623..0177bf2 100644
--- a/src/daemon/dlt_daemon_connection.c
+++ b/src/daemon/dlt_daemon_connection.c
@@ -70,6 +70,8 @@ DLT_STATIC int dlt_connection_send(DltConnection *conn,
size_t msg_size)
{
DltConnectionType type = DLT_CONNECTION_TYPE_MAX;
+ int bytes_sent = 0;
+ int ret = 0;
if ((conn != NULL) && (conn->receiver != NULL))
{
@@ -78,14 +80,22 @@ DLT_STATIC int dlt_connection_send(DltConnection *conn,
switch (type)
{
- case DLT_CONNECTION_CLIENT_MSG_SERIAL:
- if(write(conn->receiver->fd, msg, msg_size) > 0)
- return DLT_DAEMON_ERROR_OK;
- return DLT_DAEMON_ERROR_UNKNOWN;
- case DLT_CONNECTION_CLIENT_MSG_TCP:
- return dlt_daemon_socket_sendreliable(conn->receiver->fd, msg, msg_size);
- default:
- return DLT_DAEMON_ERROR_UNKNOWN;
+ case DLT_CONNECTION_CLIENT_MSG_SERIAL:
+ if (write(conn->receiver->fd, msg, msg_size) > 0)
+ {
+ return DLT_DAEMON_ERROR_OK;
+ }
+ return DLT_DAEMON_ERROR_UNKNOWN;
+
+ case DLT_CONNECTION_CLIENT_MSG_TCP:
+ ret = dlt_daemon_socket_sendreliable(conn->receiver->fd,
+ msg,
+ msg_size,
+ &bytes_sent);
+ conn->receiver->bytes_sent += bytes_sent;
+ return ret;
+ default:
+ return DLT_DAEMON_ERROR_UNKNOWN;
}
}
@@ -124,7 +134,7 @@ int dlt_connection_send_multiple(DltConnection *con,
sizeof(dltSerialHeader));
}
- if ((data1 != NULL) && (ret == DLT_RETURN_OK ))
+ if ((data1 != NULL) && (ret == DLT_RETURN_OK))
{
ret = dlt_connection_send(con, data1, size1);
}