From cd3b5886010d0bb74a90ef620e7be6f79abfc2ad Mon Sep 17 00:00:00 2001 From: Chris Elston Date: Fri, 17 Sep 2021 11:52:22 +0100 Subject: [PATCH] Fix dynamic bridge start-up delay Signed-off-by: Chris Elston The first packet sent by a dynamic bridge was failing because it was sent before the socket was fully established and the OS returned -EAGAIN. We had to wait for the next PINGREQ to cause the initial packet to be sent, and therefore bridge startup was delayed by the configured keepalive timeout (default 60 seconds). This change adds the new bridge's output socket to the list managed by the mux, and we now send the initial CONNECT as soon as the output socket becomes available. --- src/bridge_dynamic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bridge_dynamic.c b/src/bridge_dynamic.c index 4a34bb6f..ce6348c4 100644 --- a/src/bridge_dynamic.c +++ b/src/bridge_dynamic.c @@ -74,6 +74,7 @@ int bridge__dynamic_analyse(struct mosquitto_db *db, char *topic, void* payload, log__printf(NULL, MOSQ_LOG_WARNING, "Information : Start connection with bridge %s.", config.bridges[config.bridge_count-1].name); mux__add_in(db->bridges[db->bridge_count-1]); + mux__add_out(db->bridges[db->bridge_count-1]); } }else if(strncmp("$BRIDGE/del", topic, 11)==0){ rc = bridge__dynamic_parse_payload_del_json(payload,db,index);