]> 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 c46f8bb95d59a6d79f1f9feea625355db5c2290e..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);
 
@@ -418,7 +445,7 @@ int main(int argc, char **argv)
 
        /* RNH init */
        zebra_rnh_init();
-       
+
        /* Error init */
        zebra_error_init();