diff options
author | Chris Hall <chris.hall@highwayman.com> | 2011-03-29 19:47:32 +0100 |
---|---|---|
committer | Chris Hall <chris.hall@highwayman.com> | 2011-03-29 19:47:32 +0100 |
commit | 9c99076cf33bfa874db34151e28822f0e392ab3a (patch) | |
tree | e1630b98e0bb01ad8b26c6a50a7824eb41f0c448 | |
parent | 7e666be965b3ac61b05ccdeca2b61902bc26e172 (diff) | |
download | quagga-9c99076cf33bfa874db34151e28822f0e392ab3a.tar.bz2 quagga-9c99076cf33bfa874db34151e28822f0e392ab3a.tar.xz |
Fix compile on older gcc, and other minor fixes.
Slightly older gcc would not tolerate an offsetof() where the type part
contained a '->' -- replaced foo->bar by foo[0].bar, which is more
readily tolerated.
Fixed assert() in "--more--".
Improved some shut-down code.
-rw-r--r-- | lib/log.c | 7 | ||||
-rw-r--r-- | lib/vio_fifo.c | 6 | ||||
-rw-r--r-- | lib/vty_command.c | 7 | ||||
-rw-r--r-- | lib/vty_io_term.c | 31 |
4 files changed, 31 insertions, 20 deletions
@@ -971,6 +971,8 @@ closezlog (struct zlog *zl) { assert((zl == zlog_list) && (zl->next == NULL)) ; /* pro tem */ + LOG_LOCK() ; + closelog(); if (zl->file_fd >= 0) close (zl->file_fd) ; @@ -985,10 +987,9 @@ closezlog (struct zlog *zl) uzlog_set_effective_level(zl) ; - if (zl->filename != NULL) - free (zl->filename); - XFREE (MTYPE_ZLOG, zl); + + LOG_UNLOCK() ; } /*------------------------------------------------------------------------------ diff --git a/lib/vio_fifo.c b/lib/vio_fifo.c index 65f19411..89e42add 100644 --- a/lib/vio_fifo.c +++ b/lib/vio_fifo.c @@ -442,11 +442,11 @@ vio_fifo_clear(vio_fifo vff, bool clear_marks) lump = ddl_tail(vff->base) ; - vio_fifo_release_upto(vff, lump) ; - - vff->get_lump = lump ; + vff->get_lump = lump ; /* before releasing */ vff->end_lump = lump ; + vio_fifo_release_upto(vff, lump) ; + vio_fifo_reset_ptrs(vff) ; if (clear_marks) diff --git a/lib/vty_command.c b/lib/vty_command.c index 9aebc50f..94ba6833 100644 --- a/lib/vty_command.c +++ b/lib/vty_command.c @@ -297,6 +297,7 @@ vty_cmd_loop_exit(vty vty) uty_cmd_config_lock_check(vty, NULL_NODE) ; /* Can now close the vty */ + vty->vio->state = vc_stopped ; uty_close(vty->vio, NULL, false) ; /* not curtains */ VTY_UNLOCK() ; @@ -941,12 +942,16 @@ uty_cmd_hiatus(vty_io vio, cmd_return_code_t ret) return ret ; /* <<< exit here on CMD_WAITING */ case CMD_EOF: - case CMD_CLOSE: uty_out_accept(vio) ; /* accept any buffered remarks. */ assert(vio->real_depth > 0) ; --vio->real_depth ; break ; + case CMD_CLOSE: + uty_out_accept(vio) ; /* accept any buffered remarks. */ + vio->real_depth = 0 ; /* which it may already be */ + break ; + default: /* If not any of the above, must be an error of some kind: * diff --git a/lib/vty_io_term.c b/lib/vty_io_term.c index 0a1efc72..aea04734 100644 --- a/lib/vty_io_term.c +++ b/lib/vty_io_term.c @@ -243,7 +243,7 @@ uty_term_show_error_context(vio_vf vf, vio_fifo ebuf, uint depth) /*------------------------------------------------------------------------------ * Push output to the terminal. * - * Returns: CMD_SUCCESS -- all buffers are empty, or final + * Returns: CMD_SUCCESS -- all buffers are empty * CMD_WAITING -- all buffers are not empty * CMD_IO_ERROR -- failed -- final or not. * @@ -500,6 +500,7 @@ uty_term_ready(vio_vf vf) { vty_readiness_t ready ; utw_ret_t done ; + bool signal ; VTY_ASSERT_LOCKED() ; @@ -512,6 +513,7 @@ uty_term_ready(vio_vf vf) vio_lc_counter_reset(vf->cli->olc) ; /* do one tranche */ done = uty_term_write(vf) ; + signal = done == utw_done ; while (done != utw_error) { @@ -533,6 +535,9 @@ uty_term_ready(vio_vf vf) if (done == done_before) break ; /* quit if no change in response */ + + if (done == utw_done) + signal = true ; } ; if (done == utw_error) @@ -555,7 +560,7 @@ uty_term_ready(vio_vf vf) /* Signal the command loop if out_active and the buffers empty out. */ - if (done == utw_done) + if (signal) uty_cmd_signal(vf->vio, CMD_SUCCESS) ; } ; @@ -905,18 +910,18 @@ uty_term_write(vio_vf vf) */ assert(!cli->more_wait && !cli->more_enter) ; - if (cli->flush) - { - /* Even more exciting: is cli->flush ! - * - * This means that any incomplete line must have been flushed, above. - * So all buffers MUST be empty. - */ - assert(vio_fifo_empty(vf->obuf) && vio_lc_is_empty(cli->olc)) ; + if (!cli->flush) + return utw_stopped ; - cli->out_active = false ; - cli->flush = false ; - } ; + /* Even more exciting: is cli->flush ! + * + * This means that any incomplete line must have been flushed, above. + * So all buffers MUST be empty. + */ + assert(vio_fifo_empty(vf->obuf) && vio_lc_is_empty(cli->olc)) ; + + cli->out_active = false ; + cli->flush = false ; return utw_done ; } ; |