Skip to content

Commit 50f757c

Browse files
jmagninwlallemand
authored andcommitted
BUG/MINOR: init: enforce strict-limits when using master-worker
The strict-limits global option was introduced with commit 0fec3ab ("MINOR: init: always fail when setrlimit fails"). When used in conjuction with master-worker, haproxy will not fail when a setrlimit fails. This happens because we only exit() if master-worker isn't used. This patch removes all tests for master-worker mode for all cases covered by strict-limits scope. This should be backported from 2.1 onward. This should fix issue haproxy#1042. Reviewed by William Dauchy <[email protected]>
1 parent 6ecd593 commit 50f757c

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/haproxy.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3111,8 +3111,7 @@ int main(int argc, char **argv)
31113111
if (global.tune.options & GTUNE_STRICT_LIMITS) {
31123112
ha_alert("[%s.main()] Cannot raise FD limit to %d, limit is %d.\n",
31133113
argv[0], global.rlimit_nofile, (int)limit.rlim_cur);
3114-
if (!(global.mode & MODE_MWORKER))
3115-
exit(1);
3114+
exit(1);
31163115
}
31173116
else {
31183117
/* try to set it to the max possible at least */
@@ -3135,8 +3134,7 @@ int main(int argc, char **argv)
31353134
if (global.tune.options & GTUNE_STRICT_LIMITS) {
31363135
ha_alert("[%s.main()] Cannot fix MEM limit to %d megs.\n",
31373136
argv[0], global.rlimit_memmax);
3138-
if (!(global.mode & MODE_MWORKER))
3139-
exit(1);
3137+
exit(1);
31403138
}
31413139
else
31423140
ha_warning("[%s.main()] Cannot fix MEM limit to %d megs.\n",
@@ -3147,8 +3145,7 @@ int main(int argc, char **argv)
31473145
if (global.tune.options & GTUNE_STRICT_LIMITS) {
31483146
ha_alert("[%s.main()] Cannot fix MEM limit to %d megs.\n",
31493147
argv[0], global.rlimit_memmax);
3150-
if (!(global.mode & MODE_MWORKER))
3151-
exit(1);
3148+
exit(1);
31523149
}
31533150
else
31543151
ha_warning("[%s.main()] Cannot fix MEM limit to %d megs.\n",
@@ -3320,8 +3317,7 @@ int main(int argc, char **argv)
33203317
"Please raise 'ulimit-n' to %d or more to avoid any trouble.\n",
33213318
argv[0], (int)limit.rlim_cur, global.maxconn, global.maxsock,
33223319
global.maxsock);
3323-
if (!(global.mode & MODE_MWORKER))
3324-
exit(1);
3320+
exit(1);
33253321
}
33263322
else
33273323
ha_alert("[%s.main()] FD limit (%d) too low for maxconn=%d/maxsock=%d. "
@@ -3608,8 +3604,7 @@ int main(int argc, char **argv)
36083604
if (global.tune.options & GTUNE_STRICT_LIMITS) {
36093605
ha_alert("[%s.main()] Failed to set the raise the maximum "
36103606
"file size.\n", argv[0]);
3611-
if (!(global.mode & MODE_MWORKER))
3612-
exit(1);
3607+
exit(1);
36133608
}
36143609
else
36153610
ha_warning("[%s.main()] Failed to set the raise the maximum "
@@ -3622,8 +3617,7 @@ int main(int argc, char **argv)
36223617
if (global.tune.options & GTUNE_STRICT_LIMITS) {
36233618
ha_alert("[%s.main()] Failed to set the raise the core "
36243619
"dump size.\n", argv[0]);
3625-
if (!(global.mode & MODE_MWORKER))
3626-
exit(1);
3620+
exit(1);
36273621
}
36283622
else
36293623
ha_warning("[%s.main()] Failed to set the raise the core "

0 commit comments

Comments
 (0)