]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: use stop event instead of pthread_kill()
authorQuentin Young <qlyoung@cumulusnetworks.com>
Fri, 9 Jun 2017 18:10:59 +0000 (18:10 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 30 Nov 2017 21:18:02 +0000 (16:18 -0500)
When terminating I/O thread, just schedule an event to do any necessary
cleanup and gracefully exit instead of using a signal.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
bgpd/bgp_io.c

index eed310dec9ce48d5b91be77298fbd13f6c501b50..4369ef7a8468cf81d4c2e492b0c6c868237ed76e 100644 (file)
@@ -84,14 +84,23 @@ void *bgp_io_start(void *arg)
        return NULL;
 }
 
+static int bgp_io_finish(struct thread *thread)
+{
+       /* if we ever have resources to clean up, that code should be placed in
+        * a pthread_cleanup handler and called from here */
+
+       /* set stop flag */
+       atomic_store_explicit(&bgp_io_thread_run, false, memory_order_relaxed);
+
+       return 0;
+}
+
 int bgp_io_stop(void **result, struct frr_pthread *fpt)
 {
+       /* schedule stop job */
+       thread_add_event(fpt->master, &bgp_io_finish, NULL, 0, NULL);
 
-       bgp_io_thread_run = false;
-       /* let the loop break */
-       fpt->master->spin = false;
-       /* break poll */
-       pthread_kill(fpt->thread, SIGINT);
+       /* join */
        pthread_join(fpt->thread, result);
 
        return 0;