Correctly check for vm.overcommit_memory == 0 (#10841)

A regression caused by #10636 (released in 7.0.1) causes Redis startup warning about overcommit to be missing when needed and printed when not. 

Also, using atoi() to convert the string's value to an integer cannot discern
between an actual 0 (zero) having been read, or a conversion error.
This commit is contained in:
Johannes Truschnigg 2022-06-12 19:53:11 +02:00 committed by GitHub
parent abb2ea7e3c
commit 9f3b410050
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -150,7 +150,7 @@ int checkOvercommit(sds *error_msg) {
}
fclose(fp);
if (atoi(buf)) {
if (strtol(buf, NULL, 10) == 0) {
*error_msg = sdsnew(
"overcommit_memory is set to 0! Background save may fail under low memory condition. "
"To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the "