Code

Merge branch 'ff/processes'
[collectd.git] / src / email.c
index 6838eade148ca29c343e0cf0b71c97e5b5b238a5..b7995973dae20556392908d52298bafd79c70d88 100644 (file)
@@ -73,6 +73,7 @@
 
 #define SOCK_PATH "/tmp/.collectd-email"
 #define MAX_CONNS 5
+#define MAX_CONNS_LIMIT 16384
 
 /*
  * Private data structures
@@ -205,8 +206,17 @@ static int email_config (char *key, char *value)
        else if (0 == strcasecmp (key, "MaxConns")) {
                long int tmp = strtol (value, NULL, 0);
 
-               if (INT_MAX < tmp) {
-                       max_conns = INT_MAX;
+               if (tmp < 1) {
+                       fprintf (stderr, "email plugin: `MaxConns' was set to invalid "
+                                       "value %li, will use default %i.\n",
+                                       tmp, MAX_CONNS);
+                       max_conns = MAX_CONNS;
+               }
+               else if (tmp > MAX_CONNS_LIMIT) {
+                       fprintf (stderr, "email plugin: `MaxConns' was set to invalid "
+                                       "value %li, will use hardcoded limit %i.\n",
+                                       tmp, MAX_CONNS_LIMIT);
+                       max_conns = MAX_CONNS_LIMIT;
                }
                else {
                        max_conns = (int)tmp;