summaryrefslogtreecommitdiffstats
path: root/bgpd/bgpd.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2018-01-24 17:07:27 +0100
committerQuentin Young <qlyoung@cumulusnetworks.com>2018-01-24 21:30:55 +0100
commita715eab3ce7b3aedcd8f809fc7f7f512f29cceb9 (patch)
tree71fb5d39a494de7d4ac5257c56df411bad7922da /bgpd/bgpd.c
parentlib: streamline frr_pthreads, add default loop (diff)
downloadfrr-a715eab3ce7b3aedcd8f809fc7f7f512f29cceb9.tar.xz
frr-a715eab3ce7b3aedcd8f809fc7f7f512f29cceb9.zip
bgpd: update pthreads to use lib changes
Use the new threading facilities provided in lib/ to streamline the threads used in bgpd. In particular, all of the lifecycle code has been removed from the I/O thread and replaced with the default loop. Did not do the same to the keepalives thread as it is much smaller (doesn't need the event system). Also cleaned up some comments to match the style guide. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to '')
-rw-r--r--bgpd/bgpd.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 7db73043c..19f0c8cab 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -7470,30 +7470,33 @@ static void bgp_pthreads_init()
{
frr_pthread_init();
- frr_pthread_new("BGP i/o thread", PTHREAD_IO, bgp_io_start,
- bgp_io_stop);
- frr_pthread_new("BGP keepalives thread", PTHREAD_KEEPALIVES,
- bgp_keepalives_start, bgp_keepalives_stop);
-
- /* pre-run initialization */
- bgp_keepalives_init();
- bgp_io_init();
+ struct frr_pthread_attr io = {
+ .id = PTHREAD_IO,
+ .start = frr_pthread_attr_default.start,
+ .stop = frr_pthread_attr_default.stop,
+ .name = "BGP I/O thread",
+ };
+ struct frr_pthread_attr ka = {
+ .id = PTHREAD_KEEPALIVES,
+ .start = bgp_keepalives_start,
+ .stop = bgp_keepalives_stop,
+ .name = "BGP Keepalives thread",
+ };
+ frr_pthread_new(&io);
+ frr_pthread_new(&ka);
}
void bgp_pthreads_run()
{
- pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
+ struct frr_pthread *io = frr_pthread_get(PTHREAD_IO);
+ struct frr_pthread *ka = frr_pthread_get(PTHREAD_KEEPALIVES);
- /*
- * I/O related code assumes the thread is ready for work at all times,
- * so we wait until it is.
- */
- frr_pthread_run(PTHREAD_IO, &attr, NULL);
- bgp_io_wait_running();
+ frr_pthread_run(io, NULL);
+ frr_pthread_run(ka, NULL);
- frr_pthread_run(PTHREAD_KEEPALIVES, &attr, NULL);
+ /* Wait until threads are ready. */
+ frr_pthread_wait_running(io);
+ frr_pthread_wait_running(ka);
}
void bgp_pthreads_finish()