Improved ACLK reconnection sequence (#8729)
Improved ACLK reconnection sequence
Stelios Fragkakis committed
Apr 16, 2020 at 10:07 UTC
84101a234a6c3e138c6be3a9dc4c03a89e689333
1 file changed
+3
-1
aclk/agent_cloud_link.c
+3
-1
@@ -1257,11 +1257,11 @@ static void aclk_try_to_connect(char *hostname, char *port, int port_num)
1257
if (aclk_password == NULL)
1258
return;
1259
int rc;
1260
+ aclk_connecting = 1;
1261
rc = mqtt_attempt_connection(hostname, port_num, aclk_username, aclk_password);
1262
if (unlikely(rc)) {
1263
error("Failed to initialize the agent cloud link library");
1264
}
1264
- aclk_connecting = 1;
1265
}
1266
1267
@@ -1355,6 +1355,8 @@ void *aclk_main(void *ptr)
1355
}
1356
1357
_link_event_loop();
1358
+ if (unlikely(!aclk_connected))
1359
+ continue;
1360
/*static int stress_counter = 0;
1361
if (write_q_bytes==0 && stress_counter ++ >5)
1362
{