mirror of
https://github.com/redis/redis.git
synced 2026-04-21 03:01:35 -04:00
Fix boundary problem of adjusting open files limit. (#5722)
When `decr_step` is greater than `oldlimit`, the final `bestlimit` may be invalid.
For example, oldlimit = 10, decr_step = 16.
Current bestlimit = 15 and setrlimit() failed. Since bestlimit is less than decr_step , then exit the loop.
The final bestlimit is larger than oldlimit but is invalid.
Note that this only matters if the system fd limit is below 16, so unlikely to have any actual effect.
This commit is contained in:
@@ -2942,7 +2942,10 @@ void adjustOpenFilesLimit(void) {
|
||||
|
||||
/* We failed to set file limit to 'bestlimit'. Try with a
|
||||
* smaller limit decrementing by a few FDs per iteration. */
|
||||
if (bestlimit < decr_step) break;
|
||||
if (bestlimit < decr_step) {
|
||||
bestlimit = oldlimit;
|
||||
break;
|
||||
}
|
||||
bestlimit -= decr_step;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user