From 33dd1f7747ecb4e16fb807af6673592d1b0d4c3d Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 2 Nov 2016 14:40:12 +0100 Subject: [PATCH] dmeventd: abort on internal error Provide same support for DM_ABORT_ON_INTERNAL_ERRORS we do have with default libdm logging as dmeventd is libdm based tool. --- WHATS_NEW_DM | 1 + daemons/dmeventd/libdevmapper-event.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 8cf0e0588..fa77d10c8 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.136 - ====================================== + Dmeventd now also respects DM_ABORT_ON_INTERNAL_ERRORS as libdm based tool. Report as non default dm logging also when logging with errno was changed. Use log_level() macro to consistently decode message log level in dmeventd. Still produce output when dmsetup dependency tree building finds dev missing. diff --git a/daemons/dmeventd/libdevmapper-event.c b/daemons/dmeventd/libdevmapper-event.c index 8c21537d9..12173fd6a 100644 --- a/daemons/dmeventd/libdevmapper-event.c +++ b/daemons/dmeventd/libdevmapper-event.c @@ -865,6 +865,7 @@ void dm_event_log(const char *subsys, int level, const char *file, int line, int dm_errno_or_class, const char *format, va_list ap) { + static int _abort_on_internal_errors = -1; static pthread_mutex_t _log_mutex = PTHREAD_MUTEX_INITIALIZER; static time_t start = 0; const char *indent = ""; @@ -926,6 +927,15 @@ void dm_event_log(const char *subsys, int level, const char *file, } pthread_mutex_unlock(&_log_mutex); + + if (_abort_on_internal_errors < 0) + /* Set when env DM_ABORT_ON_INTERNAL_ERRORS is not "0" */ + _abort_on_internal_errors = + strcmp(getenv("DM_ABORT_ON_INTERNAL_ERRORS") ? : "0", "0"); + + if (_abort_on_internal_errors && + !strncmp(format, INTERNAL_ERROR, sizeof(INTERNAL_ERROR) - 1)) + abort(); } #if 0 /* left out for now */