From 73be9aeb1347b50838aa84f49d966cc1fa92144e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=9Fingen?= Date: Tue, 21 Mar 2017 12:06:58 +0100 Subject: [PATCH] ldpd: Catch signal on reconnect MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit To be able to interrupt LDE when it's trying to reconnect to label manager. Signed-off-by: ßingen --- ldpd/lde.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/ldpd/lde.c b/ldpd/lde.c index eece8f184f..53a9be6ae6 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -115,6 +115,14 @@ static struct quagga_signal_t lde_signals[] = }, }; +static void +lde_sleep (const char *message) +{ + fprintf (stderr, message); + sleep(1); + if (lde_signals[0].caught || lde_signals[1].caught) + lde_shutdown(); +} struct zclient *zclient_sync = NULL; static void zclient_sync_init(u_short instance) @@ -125,15 +133,13 @@ zclient_sync_init(u_short instance) zclient_sync->sock = -1; zclient_sync->redist_default = ZEBRA_ROUTE_LDP; zclient_sync->instance = instance; - while (zclient_socket_connect(zclient_sync) < 0) { - fprintf(stderr, "Error connecting synchronous zclient!\n"); - sleep(1); + while (zclient_socket_connect (zclient_sync) < 0) { + lde_sleep("Error connecting synchronous zclient!\n"); } /* Connect to label manager */ - while (lm_label_manager_connect(zclient_sync) != 0) { - fprintf(stderr, "Error connecting to label manager!\n"); - sleep(1); + while (lm_label_manager_connect (zclient_sync) != 0) { + lde_sleep("Error connecting to label manager!\n"); } } @@ -1599,9 +1605,8 @@ lde_label_list_init(void) label_chunk_list->del = lde_del_label_chunk; /* get first chunk */ - while (lde_get_label_chunk() != 0) { - fprintf(stderr, "Error getting first label chunk!\n"); - sleep(1); + while (lde_get_label_chunk () != 0) { + lde_sleep("Error getting first label chunk!\n"); } } -- 2.39.5