summaryrefslogtreecommitdiff
path: root/src/gateway/dlt_gateway.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gateway/dlt_gateway.c')
-rw-r--r--src/gateway/dlt_gateway.c28
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;
}