summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_main.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index 32219502..c1ac1ae2 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -77,7 +77,9 @@ void sigint (void);
void sigusr1 (void);
void sigusr2 (void);
+/* prototypes */
static void bgp_exit (int);
+static void init_second_stage(int pthreads);
static struct quagga_signal_t bgp_signals[] =
{
@@ -352,7 +354,6 @@ main (int argc, char **argv)
char *progname;
struct thread thread;
int tmp_port;
- int threaded = 0;
/* Set umask before anything for security */
umask (0027);
@@ -441,7 +442,8 @@ main (int argc, char **argv)
usage (progname, 0);
break;
case 't':
- threaded = 1;
+ if (!qpthreads_enabled)
+ init_second_stage(1);
break;
default:
usage (progname, 1);
@@ -457,6 +459,7 @@ main (int argc, char **argv)
signal_init (master, Q_SIGC(bgp_signals), bgp_signals);
zprivs_init (&bgpd_privs);
cmd_init (1);
+ install_element (CONFIG_NODE, &threaded_cmd);
vty_init (master);
memory_init ();
@@ -483,8 +486,9 @@ main (int argc, char **argv)
/* Process ID file creation. */
pid_output (pid_file);
- /* stage 2 initialisation */
- qlib_init_second_stage(threaded) ;
+ /* stage 2 initialisation, if not already done */
+ if (!qpthreads_enabled)
+ init_second_stage(0);
if (qpthreads_enabled)
{
@@ -529,3 +533,22 @@ main (int argc, char **argv)
/* Not reached. */
return (0);
}
+
+/* threaded */
+DEFUN_HID_CALL (threaded,
+ threaded_cmd,
+ "threaded",
+ "Use pthreads\n")
+{
+ if (!qpthreads_enabled)
+ init_second_stage(1);
+
+ return CMD_SUCCESS;
+}
+
+static void
+init_second_stage(int pthreads)
+{
+ qlib_init_second_stage(pthreads);
+ bgp_peer_index_mutex_init(NULL);
+}