Return 0 when config set out-of-range oom-score-adj-values (#10601)

When oom-score-adj-values is out of range, setConfigOOMScoreAdjValuesOption
should return 0, not -1, otherwise it will be considered as success.
This commit is contained in:
sundb 2022-04-19 16:31:15 +08:00 committed by GitHub
parent 85899e359e
commit 1a93804645
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -2641,7 +2641,7 @@ static int setConfigOOMScoreAdjValuesOption(standardConfig *config, sds *argv, i
if (*eptr != '\0' || val < -2000 || val > 2000) {
if (err) *err = "Invalid oom-score-adj-values, elements must be between -2000 and 2000.";
return -1;
return 0;
}
values[i] = val;

View File

@ -122,5 +122,10 @@ if {$system_name eq {linux}} {
r config set oom-score-adj absolute
assert_equal [get_oom_score_adj] $custom_oom
}
test {CONFIG SET out-of-range oom score} {
assert_error {ERR *must be between -2000 and 2000*} {r config set oom-score-adj-values "-2001 -2001 -2001"}
assert_error {ERR *must be between -2000 and 2000*} {r config set oom-score-adj-values "2001 2001 2001"}
}
}
}