]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/main.c
zebra: only perform shutdown signal processing once
[mirror_frr.git] / zebra / main.c
index 8db1c48f223bde679a58d1b0313a8b8ad4f14c7e..253b3087fbf8a88899d62e2070ce0abb6ec2b21d 100644 (file)
@@ -142,11 +142,19 @@ static void sigint(void)
        struct zebra_vrf *zvrf;
        struct listnode *ln, *nn;
        struct zserv *client;
+       static bool sigint_done;
+
+       if (sigint_done)
+               return;
+
+       sigint_done = true;
 
        zlog_notice("Terminating on signal");
 
        frr_early_fini();
 
+       zebra_dplane_pre_finish();
+
        for (ALL_LIST_ELEMENTS(zebrad.client_list, ln, nn, client))
                zserv_close_client(client);
 
@@ -170,7 +178,26 @@ static void sigint(void)
        prefix_list_reset();
        route_map_finish();
 
-       list_delete_and_null(&zebrad.client_list);
+       list_delete(&zebrad.client_list);
+
+       /* Indicate that all new dplane work has been enqueued. When that
+        * work is complete, the dataplane will enqueue an event
+        * with the 'finalize' function.
+        */
+       zebra_dplane_finish();
+}
+
+/*
+ * Final shutdown step for the zebra main thread. This is run after all
+ * async update processing has completed.
+ */
+int zebra_finalize(struct thread *dummy)
+{
+       zlog_info("Zebra final shutdown");
+
+       /* Stop dplane thread and finish any cleanup */
+       zebra_dplane_shutdown();
+
        work_queue_free_and_null(&zebrad.ribq);
        meta_queue_free(zebrad.mq);
 
@@ -292,7 +319,7 @@ int main(int argc, char **argv)
                        if (multipath_num > MULTIPATH_NUM
                            || multipath_num <= 0) {
                                flog_err(
-                                       ZEBRA_ERR_BAD_MULTIPATH_NUM,
+                                       EC_ZEBRA_BAD_MULTIPATH_NUM,
                                        "Multipath Number specified must be less than %d and greater than 0",
                                        MULTIPATH_NUM);
                                return 1;
@@ -418,7 +445,7 @@ int main(int argc, char **argv)
 
        /* RNH init */
        zebra_rnh_init();
-       
+
        /* Error init */
        zebra_error_init();