diff options
author | Bui Nguyen Quoc Thanh <Thanh.BuiNguyenQuoc@vn.bosch.com> | 2020-02-21 16:59:19 +0700 |
---|---|---|
committer | Saya Sugiura <39760799+ssugiura@users.noreply.github.com> | 2020-07-06 10:04:07 +0900 |
commit | d46840c9cd0e52dd7d133bbd64805fb9b8aa2aac (patch) | |
tree | 584e9c9fc413c97901e8ac90ab28d0f8814323aa /src | |
parent | c215d96ee6543fbc9429a1962c7d7b58593977ea (diff) | |
download | DLT-daemon-d46840c9cd0e52dd7d133bbd64805fb9b8aa2aac.tar.gz |
gateway: Support infinite loop of retry
- In order to enable endless retry of reconnection,
"Timeout" in dlt_gateway.conf must be set to 0.
- In case of "Timeout" is an integer A and A is greater than 0,
so after A times of retry, the connection to passive Node
will be marked as DISABLED.
There won't be any retry afterward.
Signed-off-by: Bui Nguyen Quoc Thanh <Thanh.BuiNguyenQuoc@vn.bosch.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gateway/dlt_gateway.c | 18 | ||||
-rw-r--r-- | src/gateway/dlt_gateway.conf | 5 |
2 files changed, 17 insertions, 6 deletions
diff --git a/src/gateway/dlt_gateway.c b/src/gateway/dlt_gateway.c index a47563a..005716e 100644 --- a/src/gateway/dlt_gateway.c +++ b/src/gateway/dlt_gateway.c @@ -193,7 +193,8 @@ DLT_STATIC DltReturnValue dlt_gateway_check_timeout(DltGatewayConnection *con, con->timeout = (int)strtol(value, NULL, 10); - if (con->timeout > 0) + + if (con->timeout >= 0) return DLT_RETURN_OK; return DLT_RETURN_ERROR; @@ -978,11 +979,16 @@ int dlt_gateway_establish_connections(DltGateway *gateway, con->timeout_cnt++; - if (con->timeout_cnt > con->timeout) { - con->trigger = DLT_GATEWAY_DISABLED; - dlt_log(LOG_WARNING, - "Passive Node connection retry timed out. " - "Give up.\n"); + if (con->timeout > 0) { + if (con->timeout_cnt > con->timeout) { + con->trigger = DLT_GATEWAY_DISABLED; + dlt_log(LOG_WARNING, + "Passive Node connection retry timed out. " + "Give up.\n"); + } + } + else if (con->timeout == 0) { + dlt_vlog(LOG_DEBUG, "Retried [%d] times\n", con->timeout_cnt); } } } diff --git a/src/gateway/dlt_gateway.conf b/src/gateway/dlt_gateway.conf index c7ef3a8..3f475e6 100644 --- a/src/gateway/dlt_gateway.conf +++ b/src/gateway/dlt_gateway.conf @@ -10,8 +10,13 @@ IPaddress=192.168.2.11 EcuID=ECU2 ; Try connect to passive Node on DLT Daemon startup. Default OnStartup if not specified. ; Connect=OnStartup + ; Stop connecting to passive node, if not successful after 10 retries. +; After <Timeout> of retries, the connection to passive Node is marked as DISABLED. +; It means there is no any retry anymore. +; Set to 0 for endless retry. Timeout=10 + ; Send following control messages after connection is established ; SendControl=0x03,0x04,0x13 ; Send Serial Header with control messages. Value in dlt.conf is used as default if not specified. |