Looks good, thanks. Ethan
On Tue, May 22, 2012 at 5:19 PM, Ben Pfaff <b...@nicira.com> wrote: > Whereas VLOG_FATAL() eventually calls exit(1), VLOG_ABORT() > eventually calls abort(). The key difference is that abort() > will cause a "monitor" process to restart, where exit(1) will > cause it to exit along with the monitored process. > > Signed-off-by: Ben Pfaff <b...@nicira.com> > --- > lib/util.c | 9 +++++++-- > lib/util.h | 2 ++ > lib/vlog.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ > lib/vlog.h | 6 ++++++ > 4 files changed, 61 insertions(+), 2 deletions(-) > > diff --git a/lib/util.c b/lib/util.c > index bc5fa98..cbcf693 100644 > --- a/lib/util.c > +++ b/lib/util.c > @@ -199,9 +199,14 @@ ovs_abort(int err_no, const char *format, ...) > va_list args; > > va_start(args, format); > - ovs_error_valist(err_no, format, args); > - va_end(args); > + ovs_abort_valist(err_no, format, args); > +} > > +/* Same as ovs_abort() except that the arguments are supplied as a va_list. > */ > +void > +ovs_abort_valist(int err_no, const char *format, va_list args) > +{ > + ovs_error_valist(err_no, format, args); > abort(); > } > > diff --git a/lib/util.h b/lib/util.h > index dd86de2..809ae9c 100644 > --- a/lib/util.h > +++ b/lib/util.h > @@ -188,6 +188,8 @@ void ovs_strzcpy(char *dst, const char *src, size_t size); > > void ovs_abort(int err_no, const char *format, ...) > PRINTF_FORMAT(2, 3) NO_RETURN; > +void ovs_abort_valist(int err_no, const char *format, va_list) > + PRINTF_FORMAT(2, 0) NO_RETURN; > void ovs_fatal(int err_no, const char *format, ...) > PRINTF_FORMAT(2, 3) NO_RETURN; > void ovs_fatal_valist(int err_no, const char *format, va_list) > diff --git a/lib/vlog.c b/lib/vlog.c > index 4c12007..fdc1b17 100644 > --- a/lib/vlog.c > +++ b/lib/vlog.c > @@ -738,6 +738,12 @@ vlog(const struct vlog_module *module, enum vlog_level > level, > va_end(args); > } > > +/* Logs 'message' to 'module' at maximum verbosity, then exits with a failure > + * exit code. Always writes the message to stderr, even if the console > + * facility is disabled. > + * > + * Choose this function instead of vlog_abort_valist() if the daemon > monitoring > + * facility shouldn't automatically restart the current daemon. */ > void > vlog_fatal_valist(const struct vlog_module *module_, > const char *message, va_list args) > @@ -752,6 +758,12 @@ vlog_fatal_valist(const struct vlog_module *module_, > ovs_fatal_valist(0, message, args); > } > > +/* Logs 'message' to 'module' at maximum verbosity, then exits with a failure > + * exit code. Always writes the message to stderr, even if the console > + * facility is disabled. > + * > + * Choose this function instead of vlog_abort() if the daemon monitoring > + * facility shouldn't automatically restart the current daemon. */ > void > vlog_fatal(const struct vlog_module *module, const char *message, ...) > { > @@ -762,6 +774,40 @@ vlog_fatal(const struct vlog_module *module, const char > *message, ...) > va_end(args); > } > > +/* Logs 'message' to 'module' at maximum verbosity, then calls abort(). > Always > + * writes the message to stderr, even if the console facility is disabled. > + * > + * Choose this function instead of vlog_fatal_valist() if the daemon > monitoring > + * facility should automatically restart the current daemon. */ > +void > +vlog_abort_valist(const struct vlog_module *module_, > + const char *message, va_list args) > +{ > + struct vlog_module *module = (struct vlog_module *) module_; > + > + /* Don't log this message to the console to avoid redundancy with the > + * message written by the later ovs_abort_valist(). */ > + module->levels[VLF_CONSOLE] = VLL_OFF; > + > + vlog_valist(module, VLL_EMER, message, args); > + ovs_abort_valist(0, message, args); > +} > + > +/* Logs 'message' to 'module' at maximum verbosity, then calls abort(). > Always > + * writes the message to stderr, even if the console facility is disabled. > + * > + * Choose this function instead of vlog_fatal() if the daemon monitoring > + * facility should automatically restart the current daemon. */ > +void > +vlog_abort(const struct vlog_module *module, const char *message, ...) > +{ > + va_list args; > + > + va_start(args, message); > + vlog_abort_valist(module, message, args); > + va_end(args); > +} > + > bool > vlog_should_drop(const struct vlog_module *module, enum vlog_level level, > struct vlog_rate_limit *rl) > diff --git a/lib/vlog.h b/lib/vlog.h > index 3b00512..6dfaf3f 100644 > --- a/lib/vlog.h > +++ b/lib/vlog.h > @@ -151,6 +151,11 @@ void vlog_fatal(const struct vlog_module *, const char > *format, ...) > void vlog_fatal_valist(const struct vlog_module *, const char *format, > va_list) > PRINTF_FORMAT (2, 0) NO_RETURN; > > +void vlog_abort(const struct vlog_module *, const char *format, ...) > + PRINTF_FORMAT (2, 3) NO_RETURN; > +void vlog_abort_valist(const struct vlog_module *, const char *format, > va_list) > + PRINTF_FORMAT (2, 0) NO_RETURN; > + > void vlog_rate_limit(const struct vlog_module *, enum vlog_level, > struct vlog_rate_limit *, const char *, ...) > PRINTF_FORMAT (4, 5); > @@ -169,6 +174,7 @@ void vlog_rate_limit(const struct vlog_module *, enum > vlog_level, > * Guaranteed to preserve errno. > */ > #define VLOG_FATAL(...) vlog_fatal(THIS_MODULE, __VA_ARGS__) > +#define VLOG_ABORT(...) vlog_abort(THIS_MODULE, __VA_ARGS__) > #define VLOG_EMER(...) VLOG(VLL_EMER, __VA_ARGS__) > #define VLOG_ERR(...) VLOG(VLL_ERR, __VA_ARGS__) > #define VLOG_WARN(...) VLOG(VLL_WARN, __VA_ARGS__) > -- > 1.7.2.5 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev