Code

email plugin: Ignore size if it less than or equal to zero. collectd-3.11.0
authorSebastian Harl <sh@tokkee.org>
Sun, 24 Dec 2006 13:22:49 +0000 (14:22 +0100)
committerFlorian Forster <octo@huhu.verplant.org>
Tue, 9 Jan 2007 13:54:31 +0000 (14:54 +0100)
Some daemons (e.g. postgrey) don't provide any size information.

Signed-off-by: Sebastian Harl <sh@tokkee.org>
src/collectd.pod
src/email.c

index bf76055f0cac9e29041e3e9b1de974937b180cf6..8ee77ea26a8fec042a49d33eed80e0e99bf14f3b 100644 (file)
@@ -202,6 +202,8 @@ E-Mail type (e.g. "ham", "spam", "virus", ...) and size (bytes):
 
   e:<type>:<size>
 
+If C<size> is less than or equal to zero, C<size> is ignored.
+
 Spam score:
 
   s:<value>
index 64b82e465c1af5ea9df81f0eb59fbfdf50f7478e..509eb2305532c9d1d199ed441640df470cf4316a 100644 (file)
@@ -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:<value> */
                                pthread_mutex_lock (&score_mutex);