Browse code

dmq: attempt to re-initialize if node becomes detatched from cluster

- issue reported by José Seabra on sr-users mailing list

(cherry picked from commit 666ebb63aecf2254b8efeae261452fc75c6d3aed)

Charles Chance authored on 28/03/2017 12:13:55 • Daniel-Constantin Mierla committed on 04/04/2017 11:52:37
Showing 1 changed files
... ...
@@ -459,12 +459,28 @@ void ping_servers(unsigned int ticks, void *param) {
459 459
 	str* body;
460 460
 	int ret;
461 461
 	LM_DBG("ping_servers\n");
462
+
463
+	if (!node_list->nodes || (node_list->nodes->local && !node_list->nodes->next)) {
464
+		LM_DBG("node list is empty - attempt to rebuild from notification address\n");
465
+		*dmq_init_callback_done = 0;
466
+		if(dmq_notification_address.s) {
467
+			notification_node = add_server_and_notify(&dmq_notification_address);
468
+			if(!notification_node) {
469
+				LM_ERR("cannot retrieve initial nodelist from %.*s\n",
470
+					STR_FMT(&dmq_notification_address));
471
+			}
472
+		} else {
473
+			LM_ERR("no notification address");
474
+		}
475
+		return;
476
+	}
477
+
462 478
 	body = build_notification_body();
463 479
 	if (!body) {
464 480
 		LM_ERR("could not build notification body\n");
465 481
 		return;
466 482
 	}
467
-	ret = bcast_dmq_message(dmq_notification_peer, body, notification_node,
483
+	ret = bcast_dmq_message(dmq_notification_peer, body, NULL,
468 484
 			&notification_callback, 1, &notification_content_type);
469 485
 	pkg_free(body->s);
470 486
 	pkg_free(body);