diff options
author | paulo <paul@bayleaf.org.uk> | 2010-01-06 12:10:20 +0000 |
---|---|---|
committer | paulo <paul@bayleaf.org.uk> | 2010-01-06 12:10:20 +0000 |
commit | 10a698df4dbb2587332cb8e9c040775311560dfc (patch) | |
tree | 5e9a38271f58a508c5c942e5b36269afacae31da | |
parent | f2c33e324e1d6194f3f5ca6f3b8f6d08cce8fb69 (diff) | |
download | quagga-10a698df4dbb2587332cb8e9c040775311560dfc.tar.bz2 quagga-10a698df4dbb2587332cb8e9c040775311560dfc.tar.xz |
Added "threaded" command.
-rw-r--r-- | bgpd/bgp_main.c | 31 |
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); +} |