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. 30
      src/resources.cpp

30
src/resources.cpp

@ -42,25 +42,29 @@ namespace mergerfs
int
maxout_rlimit(int resource)
{
int rv;
struct rlimit rlim;
if(geteuid() == 0)
{
rlim.rlim_cur = RLIM_INFINITY;
rlim.rlim_max = RLIM_INFINITY;
}
else
{
int rv;
rlim.rlim_cur = RLIM_INFINITY;
rlim.rlim_max = RLIM_INFINITY;
rv = ::setrlimit(resource,&rlim);
if(rv == 0)
return 0;
rv = ::getrlimit(resource,&rlim);
if(rv == -1)
return -1;
rv = ::getrlimit(resource,&rlim);
if(rv == -1)
return -1;
rlim.rlim_cur = rlim.rlim_max;
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;
}
return ::setrlimit(resource,&rlim);
return rv;
}
int

Loading…
Cancel
Save