summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_main.c
diff options
context:
space:
mode:
authorpaulo <paul@bayleaf.org.uk>2010-01-22 18:04:18 +0000
committerpaulo <paul@bayleaf.org.uk>2010-01-22 18:04:18 +0000
commiteeda1184fa60c5077c2d404d0a8415d11e836ccd (patch)
tree2fbf5caf7362cfb47d2a84cdacac0283ec77aa72 /bgpd/bgp_main.c
parent27d6ee80efd93c2f82de06787483630756164605 (diff)
downloadquagga-eeda1184fa60c5077c2d404d0a8415d11e836ccd.tar.bz2
quagga-eeda1184fa60c5077c2d404d0a8415d11e836ccd.tar.xz
Fix "write file" command so reports "threaded". Working on Shutdown and
HUP. Shutdown needs mechanism to know when bgp_engine has closed everything. HUP don't understand how it is supposed to cope with added/ deleted/retained peers and get them going again.
Diffstat (limited to 'bgpd/bgp_main.c')
-rw-r--r--bgpd/bgp_main.c71
1 files changed, 60 insertions, 11 deletions
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index 45ea0f59..88068017 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -85,6 +85,10 @@ static void init_second_stage(int pthreads);
static void bgp_in_thread_init(void);
static qtime_mono_t routing_event_hook(void);
static qtime_mono_t bgp_event_hook(void);
+static void sighup_action(mqueue_block mqb, mqb_flag_t flag);
+static void sighup_enqueue(void);
+static void sigterm_action(mqueue_block mqb, mqb_flag_t flag);
+static void sigterm_enqueue(void);
static struct quagga_signal_t bgp_signals[] =
{
@@ -189,9 +193,9 @@ sighup (void)
{
zlog (NULL, LOG_INFO, "SIGHUP received");
- /* Terminate all thread. */
- bgp_terminate ();
- bgp_reset ();
+ /* tell the routing engine */
+ sighup_enqueue();
+
zlog_info ("bgpd restarting!");
/* Reload config file. */
@@ -212,18 +216,18 @@ sigint (void)
#endif
zlog_notice ("Terminating on signal");
- if (!retain_mode)
- bgp_terminate ();
+ /* tell the routing engine */
+ sigterm_enqueue();
- if (qpthreads_enabled)
- {
- /* ask all threads to terminate */
- if (routing_nexus != NULL)
+ /* TODO: very temporary kludge to test if bgp engine does close */
+ sleep(20);
+
+ /* ask remaining pthreads to die */
+ if (qpthreads_enabled && routing_nexus != NULL)
qpn_terminate(routing_nexus);
- if (bgp_nexus != NULL)
+ if (qpthreads_enabled && bgp_nexus != NULL)
qpn_terminate(bgp_nexus);
- }
if (cli_nexus != NULL)
qpn_terminate(cli_nexus);
@@ -623,3 +627,48 @@ bgp_event_hook(void)
bgp_connection_queue_process();
return 0;
}
+
+/* SIGINT/TERM SIGHUP need to tell routing engine what to do */
+
+static void
+sighup_enqueue(void)
+{
+ mqueue_block mqb = mqb_init_new(NULL, sighup_action, NULL) ;
+
+ mqueue_enqueue(routing_nexus->queue, mqb, 0) ;
+}
+
+/* dispatch a command from the message queue block */
+static void
+sighup_action(mqueue_block mqb, mqb_flag_t flag)
+{
+ if (flag == mqb_action)
+ {
+ bgp_terminate ();
+ bgp_reset ();
+ }
+
+ mqb_free(mqb);
+}
+
+static void
+sigterm_enqueue(void)
+{
+ mqueue_block mqb = mqb_init_new(NULL, sigterm_action, NULL) ;
+
+ mqueue_enqueue(routing_nexus->queue, mqb, 0) ;
+}
+
+/* dispatch a command from the message queue block */
+static void
+sigterm_action(mqueue_block mqb, mqb_flag_t flag)
+{
+ if (flag == mqb_action)
+ {
+ /* send notify to all peers, unless retaining routes */
+ if (!retain_mode)
+ bgp_terminate();
+ }
+
+ mqb_free(mqb);
+}