summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlvklevankhanh <119659574+lvklevankhanh@users.noreply.github.com>2023-02-28 15:50:04 +0700
committerGitHub <noreply@github.com>2023-02-28 15:50:04 +0700
commit0a06fcb4a3e4fdc6a844247fe2344e3b296e2c4d (patch)
tree3f838bbc74863b4b1757fc53134daa50d9b11564
parente97c14faa6560a882c3d861540b804f1af5e47d0 (diff)
parent4501146661a68c30a70574757f9197c04ba2d723 (diff)
downloadDLT-daemon-0a06fcb4a3e4fdc6a844247fe2344e3b296e2c4d.tar.gz
Merge pull request #439 from alexmohr/add-socket-timeout
dlt-connection: add socket timeout
-rw-r--r--src/daemon/dlt_daemon_connection.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/daemon/dlt_daemon_connection.c b/src/daemon/dlt_daemon_connection.c
index 805afed..1658e26 100644
--- a/src/daemon/dlt_daemon_connection.c
+++ b/src/daemon/dlt_daemon_connection.c
@@ -402,6 +402,21 @@ int dlt_connection_create(DltDaemonLocal *daemon_local,
return -1;
}
+ struct timeval timeout;
+ timeout.tv_sec = 5;
+ timeout.tv_usec = 0;
+#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+ char *watchdogUSec = getenv("WATCHDOG_USEC");
+ if (watchdogUSec) {
+ timeout.tv_sec = atoi(watchdogUSec) / 1000000;
+ timeout.tv_usec = atoi(watchdogUSec) % 1000000;
+ }
+#endif
+
+ if (setsockopt (temp->receiver->fd, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof timeout) < 0) {
+ dlt_vlog(LOG_WARNING, "Unable to set send timeout %s.\n", strerror(errno));
+ }
+
/* We are single threaded no need for protection. */
temp->id = connectionId++;