summaryrefslogtreecommitdiffstats
path: root/lib/vty.c
diff options
context:
space:
mode:
authorpaulo <paul@bayleaf.org.uk>2009-12-14 17:38:26 +0000
committerpaulo <paul@bayleaf.org.uk>2009-12-14 17:38:26 +0000
commit73fe495cffb7eae3f68df3d3598b0f83df81b79a (patch)
tree2e67e49a094ad232bf883b6e5141798da03fa6f9 /lib/vty.c
parent9035f1d22beec82507c1c9137e7c9fb5c4d0fbc6 (diff)
downloadquagga-73fe495cffb7eae3f68df3d3598b0f83df81b79a.tar.bz2
quagga-73fe495cffb7eae3f68df3d3598b0f83df81b79a.tar.xz
Using message queue to send commands from cli thread to bgp thread.
Diffstat (limited to 'lib/vty.c')
-rw-r--r--lib/vty.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/vty.c b/lib/vty.c
index 64f99395..23f9bc9c 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -139,6 +139,7 @@ char integrate_default[] = SYSCONFDIR INTEGRATE_DEFAULT_CONFIG;
/* Master of the threads. */
static struct thread_master *master = NULL;
static qpn_nexus cli_nexus = NULL;
+static qpn_nexus bgp_nexus = NULL;
/* VTY standard output function. vty == NULL or VTY_SHELL => stdout */
int
@@ -226,6 +227,13 @@ uty_vout(struct vty *vty, const char *format, va_list args)
XFREE (MTYPE_VTY_OUT_BUF, p);
}
+ if (cli_nexus != NULL && qpt_thread_self() != cli_nexus->thread_id)
+ {
+ /* Wake up */
+ vty_event (VTY_WRITE, vty->fd, vty);
+ qpt_thread_signal(cli_nexus->thread_id, SIGMQUEUE);
+ }
+
return len;
}
@@ -546,7 +554,7 @@ vty_command (struct vty *vty, char *buf)
#endif /* CONSUMED_TIME_CHECK */
UNLOCK
- ret = cmd_execute_command (vline, vty, NULL, 0);
+ ret = cmd_execute_command (vline, vty, NULL, bgp_nexus, 0);
LOCK
/* Get the name of the protocol if any */
@@ -3465,9 +3473,10 @@ vty_init_vtysh ()
/* qpthreads: Install vty's own commands like `who' command. */
void
-vty_init_r (qpn_nexus qpn)
+vty_init_r (qpn_nexus cli_n, qpn_nexus bgp_n)
{
- cli_nexus = qpn;
+ cli_nexus = cli_n;
+ bgp_nexus = bgp_n;
vty_mutex = qpt_mutex_init(vty_mutex, qpt_mutex_quagga);
}