Commits

Roger Light committed 0c939b5

Fix bridge reconnections when using multiple bridge addresses.

Thanks to Marcel Verpaalen.

Comments (0)

Files changed (2)

 - Possible memory leak fixes. 
 - Further fix for bug #1226040: multiple retained messages being delivered for
   subscriptions ending in #.
+- Fix bridge reconnections when using multiple bridge addresses.
 
 Client library:
 - Fix possible memory leak in C/C++ library when communicating with
 					if(db->contexts[i]->bridge){
 						/* Want to try to restart the bridge connection */
 						if(!db->contexts[i]->bridge->restart_t){
+							printf("cur_address: %d\n", db->contexts[i]->bridge->cur_address);
 							db->contexts[i]->bridge->restart_t = now+db->contexts[i]->bridge->restart_timeout;
 							db->contexts[i]->bridge->cur_address++;
 							if(db->contexts[i]->bridge->cur_address == db->contexts[i]->bridge->address_count){
 							}
 						}else{
 							if(db->contexts[i]->bridge->start_type == bst_lazy && db->contexts[i]->bridge->lazy_reconnect){
-								mqtt3_bridge_connect(db, db->contexts[i]);
+								rc = mqtt3_bridge_connect(db, db->contexts[i]);
+								if(rc){
+									db->contexts[i]->bridge->cur_address++;
+									if(db->contexts[i]->bridge->cur_address == db->contexts[i]->bridge->address_count){
+										db->contexts[i]->bridge->cur_address = 0;
+									}
+								}
 							}
 							if(db->contexts[i]->bridge->start_type == bst_automatic && now > db->contexts[i]->bridge->restart_t){
 								db->contexts[i]->bridge->restart_t = 0;
 								}else{
 									/* Retry later. */
 									db->contexts[i]->bridge->restart_t = now+db->contexts[i]->bridge->restart_timeout;
+
+									db->contexts[i]->bridge->cur_address++;
+									if(db->contexts[i]->bridge->cur_address == db->contexts[i]->bridge->address_count){
+										db->contexts[i]->bridge->cur_address = 0;
+									}
 								}
 							}
 						}