From f047271cb963c62663687d63b2f7cf8dd5edfbb7 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Tue, 6 Jun 2017 16:47:30 +0200 Subject: [PATCH] Timers: Parse and format functions for microsecond times Date/time output (e.g. in logs, show commands) can use %f to specify subsecond time. By default, millisecond precision is used in output. --- conf/conf.c | 6 +- conf/conf.h | 2 +- conf/confbase.Y | 12 ++-- doc/bird.sgml | 28 ++++----- lib/timer.c | 135 +++++++++++++++++++++++++++++++++++++++++++ lib/timer.h | 19 ++++++ nest/cmds.c | 6 +- nest/config.Y | 39 +++++++++++-- nest/password.c | 9 ++- nest/password.h | 4 +- nest/proto.c | 10 ++-- nest/protocol.h | 4 +- nest/route.h | 4 +- nest/rt-show.c | 2 +- nest/rt-table.c | 10 ++-- proto/bfd/bfd.c | 8 +-- proto/bfd/bfd.h | 2 +- sysdep/unix/config.Y | 26 +-------- sysdep/unix/io.c | 97 +------------------------------ sysdep/unix/log.c | 2 +- sysdep/unix/timer.h | 12 ---- 21 files changed, 244 insertions(+), 193 deletions(-) diff --git a/conf/conf.c b/conf/conf.c index c4933122..a570fad5 100644 --- a/conf/conf.c +++ b/conf/conf.c @@ -102,9 +102,9 @@ config_alloc(const char *name) c->pool = p; c->mem = l; c->file_name = ndup; - c->load_time = now; - c->tf_route = c->tf_proto = (struct timeformat){"%T", "%F", 20*3600}; - c->tf_base = c->tf_log = (struct timeformat){"%F %T", NULL, 0}; + c->load_time = current_time(); + c->tf_route = c->tf_proto = TM_ISO_SHORT_MS; + c->tf_base = c->tf_log = TM_ISO_LONG_MS; c->gr_wait = DEFAULT_GR_WAIT; return c; diff --git a/conf/conf.h b/conf/conf.h index af92f056..552d0120 100644 --- a/conf/conf.h +++ b/conf/conf.h @@ -57,7 +57,7 @@ struct config { struct config *fallback; /* Link to regular config for CLI parsing */ int obstacle_count; /* Number of items blocking freeing of this config */ int shutdown; /* This is a pseudo-config for daemon shutdown */ - bird_clock_t load_time; /* When we've got this configuration */ + btime load_time; /* When we've got this configuration */ }; /* Please don't use these variables in protocols. Use proto_config->global instead. */ diff --git a/conf/confbase.Y b/conf/confbase.Y index 901ca2b2..390041c4 100644 --- a/conf/confbase.Y +++ b/conf/confbase.Y @@ -14,7 +14,7 @@ CF_HDR #include "conf/conf.h" #include "lib/resource.h" #include "lib/socket.h" -#include "sysdep/unix/timer.h" +#include "lib/timer.h" #include "lib/string.h" #include "nest/protocol.h" #include "nest/iface.h" @@ -60,7 +60,7 @@ CF_DECLS struct lsadb_show_data *ld; struct iface *iface; void *g; - bird_clock_t time; + btime time; struct f_prefix px; struct proto_spec ps; struct channel_limit cl; @@ -81,7 +81,7 @@ CF_DECLS %type expr bool pxlen4 %type expr_us -%type