Browse Source

Merge pull request #51 from trapexit/rlimits

Try RLIMIT_INFINITY first, then cur = max, then loop and try to increase...
pull/55/head 1.7.1
Antonio SJ Musumeci 10 years ago
parent
commit
e0f0bb53f7
  1. 18
      src/resources.cpp

18
src/resources.cpp

@ -42,25 +42,29 @@ namespace mergerfs
int int
maxout_rlimit(int resource) maxout_rlimit(int resource)
{ {
int rv;
struct rlimit rlim; struct rlimit rlim;
if(geteuid() == 0)
{
rlim.rlim_cur = RLIM_INFINITY; rlim.rlim_cur = RLIM_INFINITY;
rlim.rlim_max = RLIM_INFINITY; rlim.rlim_max = RLIM_INFINITY;
}
else
{
int rv;
rv = ::setrlimit(resource,&rlim);
if(rv == 0)
return 0;
rv = ::getrlimit(resource,&rlim); rv = ::getrlimit(resource,&rlim);
if(rv == -1) if(rv == -1)
return -1; return -1;
rv = 0;
rlim.rlim_cur = rlim.rlim_max;
while(rv == 0)
{
rv = ::setrlimit(resource,&rlim);
rlim.rlim_max *= 2;
rlim.rlim_cur = rlim.rlim_max; rlim.rlim_cur = rlim.rlim_max;
} }
return ::setrlimit(resource,&rlim);
return rv;
} }
int int

Loading…
Cancel
Save