fp[32 * from + to]++;
}
+/* checks that the numerical argument, if passed without units and is non-zero,
+ * is at least as large as value <min>. It returns 1 if the value is too small,
+ * otherwise zero. This is used to warn about the use of small values without
+ * units.
+ */
+static inline int warn_if_lower(const char *text, long min)
+{
+ int digits;
+ long value;
+
+ digits = strspn(text, "0123456789");
+ if (digits < strlen(text))
+ return 0; // there are non-digits here.
+
+ value = atol(text);
+ return value && value < min;
+}
/* compare the current OpenSSL version to a string */
int openssl_compare_current_version(const char *version);
}
srv->agent.inter = delay;
+ if (warn_if_lower(args[*cur_arg+1], 100)) {
+ memprintf(errmsg, "'%s %u' in server '%s' is suspiciously small for a value in milliseconds. Please use an explicit unit ('%ums') if that was the intent",
+ args[*cur_arg], delay, srv->id, delay);
+ err_code |= ERR_WARN;
+ }
+
out:
return err_code;
}
srv->check.inter = delay;
+ if (warn_if_lower(args[*cur_arg+1], 100)) {
+ memprintf(errmsg, "'%s %u' in server '%s' is suspiciously small for a value in milliseconds. Please use an explicit unit ('%ums') if that was the intent",
+ args[*cur_arg], delay, srv->id, delay);
+ err_code |= ERR_WARN;
+ }
+
out:
return err_code;
}
srv->check.fastinter = delay;
+ if (warn_if_lower(args[*cur_arg+1], 100)) {
+ memprintf(errmsg, "'%s %u' in server '%s' is suspiciously small for a value in milliseconds. Please use an explicit unit ('%ums') if that was the intent",
+ args[*cur_arg], delay, srv->id, delay);
+ err_code |= ERR_WARN;
+ }
+
out:
return err_code;
}
srv->check.downinter = delay;
+ if (warn_if_lower(args[*cur_arg+1], 100)) {
+ memprintf(errmsg, "'%s %u' in server '%s' is suspiciously small for a value in milliseconds. Please use an explicit unit ('%ums') if that was the intent",
+ args[*cur_arg], delay, srv->id, delay);
+ err_code |= ERR_WARN;
+ }
+
out:
return err_code;
return -1;
}
+ if (warn_if_lower(args[1], 100)) {
+ memprintf(err, "'timeout %s %u' in %s '%s' is suspiciously small for a value in milliseconds. Please use an explicit unit ('%ums') if that was the intent.",
+ name, timeout, proxy_type_str(proxy), proxy->id, timeout);
+ retval = 1;
+ }
+
if (!(proxy->cap & cap)) {
memprintf(err, "'timeout %s' will be ignored because %s '%s' has no %s capability",
name, proxy_type_str(proxy), proxy->id,
goto out;
}
+ if (warn_if_lower(args[2], 100)) {
+ ha_alert("parsing [%s:%d] : '%s %s %u' looks suspiciously small for a value in milliseconds."
+ " Please use an explicit unit ('%ums') if that was the intent.\n",
+ file, linenum, args[0], args[1], time, time);
+ err_code |= ERR_WARN;
+ }
}
else if (strcmp(args[0], "accepted_payload_size") == 0) {
int i = 0;
curr_resolvers->px->timeout.connect = tout;
}
+ if (warn_if_lower(args[2], 100)) {
+ ha_alert("parsing [%s:%d] : '%s %s %u' looks suspiciously small for a value in milliseconds."
+ " Please use an explicit unit ('%ums') if that was the intent.\n",
+ file, linenum, args[0], args[1], tout, tout);
+ err_code |= ERR_WARN;
+ }
}
else {
ha_alert("parsing [%s:%d] : '%s' expects 'retry' or 'resolve' and <time> as arguments got '%s'.\n",