From 07d5fdf21191d401d5ad06f49d689b6cdeda1635 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sun, 24 Dec 2006 14:22:49 +0100 Subject: [PATCH] email plugin: Ignore size if it less than or equal to zero. Some daemons (e.g. postgrey) don't provide any size information. Signed-off-by: Sebastian Harl --- src/collectd.pod | 2 ++ src/email.c | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/collectd.pod b/src/collectd.pod index bf76055f..8ee77ea2 100644 --- a/src/collectd.pod +++ b/src/collectd.pod @@ -202,6 +202,8 @@ E-Mail type (e.g. "ham", "spam", "virus", ...) and size (bytes): e:: +If C is less than or equal to zero, C is ignored. + Spam score: s: diff --git a/src/email.c b/src/email.c index 64b82e46..509eb230 100644 --- a/src/email.c +++ b/src/email.c @@ -486,9 +486,11 @@ static void *collect (void *arg) type_list_incr (&count, type, 1); pthread_mutex_unlock (&count_mutex); - pthread_mutex_lock (&size_mutex); - type_list_incr (&size, type, bytes); - pthread_mutex_unlock (&size_mutex); + if (bytes > 0) { + pthread_mutex_lock (&size_mutex); + type_list_incr (&size, type, bytes); + pthread_mutex_unlock (&size_mutex); + } } else if ('s' == line[0]) { /* s: */ pthread_mutex_lock (&score_mutex); -- 2.11.0