summaryrefslogtreecommitdiffstats
path: root/lib/vty_io.c
diff options
context:
space:
mode:
authorChris Hall <chris.hall@highwayman.com>2011-03-30 12:22:34 +0100
committerChris Hall <chris.hall@highwayman.com>2011-03-30 12:22:34 +0100
commitf3255d1e9f062e7783b05ab5b32ca70085170d79 (patch)
tree2545e94650e88237baf6c0e04758f00e87dc335a /lib/vty_io.c
parent9c99076cf33bfa874db34151e28822f0e392ab3a (diff)
downloadquagga-f3255d1e9f062e7783b05ab5b32ca70085170d79.tar.bz2
quagga-f3255d1e9f062e7783b05ab5b32ca70085170d79.tar.xz
Better mechanism for handling depth_mark in vty->vio.
Previous mechanism required special steps before any new output vty was opened -- which was easy to forget. New mechanism requires extra step when input and output are opened at the same time, which is less common, and more obviously requires the extra step. Fixes problem with "write memory" command.
Diffstat (limited to 'lib/vty_io.c')
-rw-r--r--lib/vty_io.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/vty_io.c b/lib/vty_io.c
index 96df3850..619f8129 100644
--- a/lib/vty_io.c
+++ b/lib/vty_io.c
@@ -252,8 +252,6 @@ uty_new(vty_type_t type, node_type_t node)
* vout_base = NULL -- empty output stack
* vout_depth = 0 -- no stacked vout's, yet
*
- * depth_mark = 0 -- no stacked vin/vout, yet
- *
* err_hard = false -- no error at all, yet
* ebuf = NULL -- no error at all, yet
*
@@ -365,12 +363,17 @@ uty_vin_new_context(vty_io vio, cmd_context context, qpath file_here)
*
* Initialises an output buffer and sets an end_mark.
*
- * The depth_mark is set to the current vio->depth_mark + 1. This is the
+ * The depth_mark is set to the current vio->vin_depth + 1. This is the
* vin_depth below which the vout should be closed. Before a command line
* is fetched (and hence after the previous command line has completed) the
* vout->depth_mark is checked. If it is > the current vin_depth, then
* the vout is closed before a command line can be fetched.
*
+ * NB: where a vin and vout are opened together, so the vout should NOT
+ * be closed until after the vin, need to call uty_vout_sync_depth()
+ * *both* the vin and the vout are pushed, in order to set the correct
+ * depth_mark.
+ *
* NB: is usually called from the cli thread, but may be called from the cmd
* thread for vf which is blocking !
*
@@ -417,12 +420,26 @@ uty_vout_push(vty_io vio, vio_vf vf, vio_out_type_t type,
vf->obuf = vio_fifo_new(obuf_size) ;
vio_fifo_set_end_mark(vf->obuf) ;
- vf->depth_mark = vio->depth_mark + 1 ;
+ vf->depth_mark = vio->vin_depth + 1 ;
vio->obuf = vf->obuf ;
} ;
/*------------------------------------------------------------------------------
+ * Synchronise vout->depth_mark to current vin_depth.
+ *
+ * This *must* be called after a vin and vout have been opened together, and
+ * they are intended to be at the same depth. This applies when the base
+ * vin/vout are opened, and when an in pipe and an out pipe are present together
+ * on a command line.
+ */
+extern void
+uty_vout_sync_depth(vty_io vio)
+{
+ vio->vout->depth_mark = vio->vin_depth ;
+} ;
+
+/*------------------------------------------------------------------------------
* Set timeout value.
*
* This is only ever called when a command (eg exec-timeout) sets a new