journald-config: always clear threshold_bytes even when boolean value is specified
Otherwise, previously specified threshold may not be cleared.
This commit is contained in:
@@ -451,36 +451,43 @@ int config_parse_compress(
|
||||
void *data,
|
||||
void *userdata) {
|
||||
|
||||
JournalCompressOptions* compress = ASSERT_PTR(data);
|
||||
JournalCompressOptions *compress = ASSERT_PTR(data);
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(rvalue);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
compress->enabled = true;
|
||||
compress->threshold_bytes = UINT64_MAX;
|
||||
} else if (streq(rvalue, "1")) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||
"Compress= ambiguously specified as 1, enabling compression with default threshold");
|
||||
compress->enabled = true;
|
||||
} else if (streq(rvalue, "0")) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||
"Compress= ambiguously specified as 0, disabling compression");
|
||||
compress->enabled = false;
|
||||
} else {
|
||||
r = parse_boolean(rvalue);
|
||||
if (r < 0) {
|
||||
r = parse_size(rvalue, 1024, &compress->threshold_bytes);
|
||||
if (r < 0)
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Failed to parse Compress= value, ignoring: %s", rvalue);
|
||||
else
|
||||
compress->enabled = true;
|
||||
} else
|
||||
compress->enabled = r;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (streq(rvalue, "1")) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||
"Compress= ambiguously specified as 1, enabling compression with default threshold.");
|
||||
compress->enabled = true;
|
||||
compress->threshold_bytes = UINT64_MAX;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (streq(rvalue, "0")) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||
"Compress= ambiguously specified as 0, disabling compression.");
|
||||
compress->enabled = false;
|
||||
compress->threshold_bytes = UINT64_MAX;
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = parse_boolean(rvalue);
|
||||
if (r >= 0) {
|
||||
compress->enabled = r;
|
||||
compress->threshold_bytes = UINT64_MAX;
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = parse_size(rvalue, 1024, &compress->threshold_bytes);
|
||||
if (r < 0)
|
||||
return log_syntax_parse_error(unit, filename, line, r, lvalue, rvalue);
|
||||
|
||||
compress->enabled = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,21 +25,21 @@
|
||||
_COMPRESS_PARSE_CHECK(str, enabled, threshold, conf##__COUNTER__)
|
||||
|
||||
TEST(config_compress) {
|
||||
COMPRESS_PARSE_CHECK("yes", true, 111);
|
||||
COMPRESS_PARSE_CHECK("no", false, 111);
|
||||
COMPRESS_PARSE_CHECK("y", true, 111);
|
||||
COMPRESS_PARSE_CHECK("n", false, 111);
|
||||
COMPRESS_PARSE_CHECK("true", true, 111);
|
||||
COMPRESS_PARSE_CHECK("false", false, 111);
|
||||
COMPRESS_PARSE_CHECK("t", true, 111);
|
||||
COMPRESS_PARSE_CHECK("f", false, 111);
|
||||
COMPRESS_PARSE_CHECK("on", true, 111);
|
||||
COMPRESS_PARSE_CHECK("off", false, 111);
|
||||
COMPRESS_PARSE_CHECK("yes", true, UINT64_MAX);
|
||||
COMPRESS_PARSE_CHECK("no", false, UINT64_MAX);
|
||||
COMPRESS_PARSE_CHECK("y", true, UINT64_MAX);
|
||||
COMPRESS_PARSE_CHECK("n", false, UINT64_MAX);
|
||||
COMPRESS_PARSE_CHECK("true", true, UINT64_MAX);
|
||||
COMPRESS_PARSE_CHECK("false", false, UINT64_MAX);
|
||||
COMPRESS_PARSE_CHECK("t", true, UINT64_MAX);
|
||||
COMPRESS_PARSE_CHECK("f", false, UINT64_MAX);
|
||||
COMPRESS_PARSE_CHECK("on", true, UINT64_MAX);
|
||||
COMPRESS_PARSE_CHECK("off", false, UINT64_MAX);
|
||||
|
||||
/* Weird size/bool overlapping case. We preserve backward compatibility instead of assuming these are byte
|
||||
* counts. */
|
||||
COMPRESS_PARSE_CHECK("1", true, 111);
|
||||
COMPRESS_PARSE_CHECK("0", false, 111);
|
||||
COMPRESS_PARSE_CHECK("1", true, UINT64_MAX);
|
||||
COMPRESS_PARSE_CHECK("0", false, UINT64_MAX);
|
||||
|
||||
/* IEC sizing */
|
||||
COMPRESS_PARSE_CHECK("1B", true, 1);
|
||||
|
||||
Reference in New Issue
Block a user