diff options
author | Saya Sugiura <ssugiura@jp.adit-jv.com> | 2019-05-23 13:56:33 +0900 |
---|---|---|
committer | Saya Sugiura <ssugiura@jp.adit-jv.com> | 2019-06-18 17:22:09 +0900 |
commit | 3580c5640c5578f508e93a8a851231b389d327cd (patch) | |
tree | efe0dd5b737e0192ea541861452c0f3f0edde099 /src/daemon/dlt_daemon_connection.c | |
parent | 341831da4da448392d62e48f1a4f419a18e3dca5 (diff) | |
download | DLT-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_connection.c')
-rw-r--r-- | src/daemon/dlt_daemon_connection.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/daemon/dlt_daemon_connection.c b/src/daemon/dlt_daemon_connection.c index 2fe17c1..456a075 100644 --- a/src/daemon/dlt_daemon_connection.c +++ b/src/daemon/dlt_daemon_connection.c @@ -71,7 +71,6 @@ 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)) @@ -88,9 +87,7 @@ DLT_STATIC int dlt_connection_send(DltConnection *conn, 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; + msg_size); return ret; default: return DLT_DAEMON_ERROR_UNKNOWN; |