diff options
author | Christoph Lipka <clipka@jp.adit-jv.com> | 2015-12-01 11:11:51 +0900 |
---|---|---|
committer | Lutz Helwing <lutz_helwing@mentor.com> | 2015-12-16 10:41:36 +0100 |
commit | c4f073db44a36cfa96a17032afedbf36e4afc3b6 (patch) | |
tree | 97be20ed225465770e06eafa83e39a5089e8d531 /src/gateway/dlt_gateway.c | |
parent | f54b52d764a7ea0f4c80e6124f5d89d3968d2906 (diff) | |
download | DLT-daemon-c4f073db44a36cfa96a17032afedbf36e4afc3b6.tar.gz |
MultiNode: Reconnection after connection loss
The Gateway DLT Daemon will try to reconnect to a passive node once
after the connection was lost.
The maximum number of reconnects can be configured by changing
the DLT_GATEWAY_RECONNECT_MAX definition.
Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
Diffstat (limited to 'src/gateway/dlt_gateway.c')
-rw-r--r-- | src/gateway/dlt_gateway.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/gateway/dlt_gateway.c b/src/gateway/dlt_gateway.c index a7d7d39..27626ee 100644 --- a/src/gateway/dlt_gateway.c +++ b/src/gateway/dlt_gateway.c @@ -634,6 +634,8 @@ int dlt_gateway_establish_connections(DltGateway *gateway, { /* connection to passive node established, add to event loop */ con->status = DLT_GATEWAY_CONNECTED; + con->reconnect_cnt = 0; + con->timeout_cnt = 0; /* setup dlt connection and add to epoll event loop here */ if (dlt_connection_create(daemon_local, @@ -745,17 +747,25 @@ int dlt_gateway_process_passive_node_messages(DltDaemon *daemon, return -1; } - con->status = DLT_GATEWAY_DISCONNECTED; - if (dlt_event_handler_unregister_connection(&daemon_local->pEvent, - daemon_local, - receiver->fd, - DLT_CONNECTION_GATEWAY) != 0) - { - dlt_log(LOG_ERR, "Remove passive node Connection failed\n"); - } - dlt_log(LOG_WARNING, "Connection to passive node lost\n"); + if (con->reconnect_cnt < DLT_GATEWAY_RECONNECT_MAX) + { + dlt_log(LOG_WARNING, "Try to reconnect.\n"); + con->reconnect_cnt += 1; + con->timeout_cnt = 0; + } + else + { + con->status = DLT_GATEWAY_DISCONNECTED; + if (dlt_event_handler_unregister_connection(&daemon_local->pEvent, + daemon_local, + receiver->fd, + DLT_CONNECTION_GATEWAY) != 0) + { + dlt_log(LOG_ERR, "Remove passive node Connection failed\n"); + } + } return 0; } |