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_connection.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_connection.c')
-rw-r--r-- | src/daemon/dlt_daemon_connection.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/daemon/dlt_daemon_connection.c b/src/daemon/dlt_daemon_connection.c index 3595981..e0cb003 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); } |