summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--zebra/main.c2
-rw-r--r--zebra/zserv.c12
-rw-r--r--zebra/zserv.h7
3 files changed, 21 insertions, 0 deletions
diff --git a/zebra/main.c b/zebra/main.c
index c605050c57..184e798bd0 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -153,7 +153,9 @@ static void sigint(void)
for (ALL_LIST_ELEMENTS(zrouter.client_list, ln, nn, client))
zserv_close_client(client);
+ zserv_close();
list_delete_all_node(zrouter.client_list);
+
zebra_ptm_finish();
if (retain_mode)
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 6532491cef..f5bb3aabb7 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -773,6 +773,18 @@ static int zserv_accept(struct thread *thread)
return 0;
}
+void zserv_close(void)
+{
+ /*
+ * On shutdown, let's close the socket down
+ * so that long running processes of killing the
+ * routing table doesn't leave us in a bad
+ * state where a client tries to reconnect
+ */
+ close(zsock);
+ zsock = -1;
+}
+
void zserv_start(char *path)
{
int ret;
diff --git a/zebra/zserv.h b/zebra/zserv.h
index c4c3e1328b..86863d961c 100644
--- a/zebra/zserv.h
+++ b/zebra/zserv.h
@@ -184,6 +184,13 @@ extern unsigned int multipath_num;
extern void zserv_init(void);
/*
+ * Stop the Zebra API server.
+ *
+ * closes the socket
+ */
+extern void zserv_close(void);
+
+/*
* Start Zebra API server.
*
* Allocates resources, creates the server socket and begins listening on the