Unverified Commit 945a83d4 authored by Garen Chan's avatar Garen Chan Committed by GitHub
Browse files

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.
parent 641780a9
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment