Browse Source

Try RLIMIT_INFINITY first, then cur = max, then loop and try to increase till error. closes #50

pull/51/head
Antonio SJ Musumeci 10 years ago
parent
commit
283a2b2285
  1. 18
      src/resources.cpp

18
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;
rv = ::setrlimit(resource,&rlim);
if(rv == 0)
return 0;
rv = ::getrlimit(resource,&rlim);
if(rv == -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;
}
return ::setrlimit(resource,&rlim);
return rv;
}
int

Loading…
Cancel
Save