Skip to content

Commit

Permalink
Set resource max limit to 10240 on macOS, GitHub #1793
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmark committed Dec 7, 2024
1 parent a311f1d commit 10aba37
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
8 changes: 4 additions & 4 deletions etc/afpd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ static int setlimits(void)
LOG(log_warning, logtype_afpd, "setlimits: reading current limits failed: %s", strerror(errno));
return -1;
}
if (rlim.rlim_cur != RLIM_INFINITY && rlim.rlim_cur < 65535) {
rlim.rlim_cur = 65535;
if (rlim.rlim_max != RLIM_INFINITY && rlim.rlim_max < 65535)
rlim.rlim_max = 65535;
if (rlim.rlim_cur != RLIM_INFINITY && rlim.rlim_cur < RLIM_MAX) {
rlim.rlim_cur = RLIM_MAX;
if (rlim.rlim_max != RLIM_INFINITY && rlim.rlim_max < RLIM_MAX)
rlim.rlim_max = RLIM_MAX;
if (setrlimit(RLIMIT_NOFILE, &rlim) != 0) {
LOG(log_warning, logtype_afpd, "setlimits: increasing limits failed: %s", strerror(errno));
return -1;
Expand Down
8 changes: 4 additions & 4 deletions etc/cnid_dbd/cnid_metad.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,10 @@ static int setlimits(void)
LOG(log_error, logtype_afpd, "setlimits: %s", strerror(errno));
exit(1);
}
if (rlim.rlim_cur != RLIM_INFINITY && rlim.rlim_cur < 65535) {
rlim.rlim_cur = 65535;
if (rlim.rlim_max != RLIM_INFINITY && rlim.rlim_max < 65535)
rlim.rlim_max = 65535;
if (rlim.rlim_cur != RLIM_INFINITY && rlim.rlim_cur < RLIM_MAX) {
rlim.rlim_cur = RLIM_MAX;
if (rlim.rlim_max != RLIM_INFINITY && rlim.rlim_max < RLIM_MAX)
rlim.rlim_max = RLIM_MAX;
if (setrlimit(RLIMIT_NOFILE, &rlim) != 0) {
LOG(log_error, logtype_afpd, "setlimits: %s", strerror(errno));
exit(1);
Expand Down
8 changes: 8 additions & 0 deletions include/atalk/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
#include <atalk/cnid.h>
#include <atalk/unicode.h>

#ifndef RLIM_MAX
#ifdef __APPLE__
#define RLIM_MAX 10240
#else
#define RLIM_MAX 65535
#endif
#endif

/* exit error codes */
#define EXITERR_CLNT 1 /* client related error */
#define EXITERR_CONF 2 /* error in config files/cmd line parameters */
Expand Down

0 comments on commit 10aba37

Please sign in to comment.