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 1, 2024
1 parent e8e567a commit 3bec172
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions etc/cnid_dbd/cnid_metad.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@
#define WTERMSIG(status) ((status) & 0x7f)
#endif

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

/* functions for username and group */
#include <pwd.h>
#include <grp.h>
Expand Down Expand Up @@ -422,10 +430,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

0 comments on commit 3bec172

Please sign in to comment.