Browse Source

Merge pull request #67 from trapexit/priority

attempt to set priority to -10 on startup. closes #65
pull/69/head 2.0.0
Antonio SJ Musumeci 10 years ago
parent
commit
ffc90f52bc
  1. 5
      src/mergerfs.cpp
  2. 10
      src/resources.cpp
  3. 3
      src/resources.hpp

5
src/mergerfs.cpp

@ -82,7 +82,7 @@ namespace local
{ {
return fs::basename(argv[0]); return fs::basename(argv[0]);
} }
static static
void void
get_fuse_operations(struct fuse_operations &ops) get_fuse_operations(struct fuse_operations &ops)
@ -152,10 +152,13 @@ namespace local
void void
setup_resources(void) setup_resources(void)
{ {
const int prio = -10;
std::srand(time(NULL)); std::srand(time(NULL));
mergerfs::resources::reset_umask(); mergerfs::resources::reset_umask();
mergerfs::resources::maxout_rlimit_nofile(); mergerfs::resources::maxout_rlimit_nofile();
mergerfs::resources::maxout_rlimit_fsize(); mergerfs::resources::maxout_rlimit_fsize();
mergerfs::resources::setpriority(prio);
} }
} }

10
src/resources.cpp

@ -40,7 +40,7 @@ namespace mergerfs
} }
int int
maxout_rlimit(int resource)
maxout_rlimit(const int resource)
{ {
int rv; int rv;
struct rlimit rlim; struct rlimit rlim;
@ -78,5 +78,13 @@ namespace mergerfs
{ {
return maxout_rlimit(RLIMIT_FSIZE); return maxout_rlimit(RLIMIT_FSIZE);
} }
int
setpriority(const int prio)
{
const int SELF = 0;
return ::setpriority(PRIO_PROCESS,SELF,prio);
}
} }
} }

3
src/resources.hpp

@ -27,8 +27,9 @@ namespace mergerfs
namespace resources namespace resources
{ {
int reset_umask(void); int reset_umask(void);
int maxout_rlimit(int resource);
int maxout_rlimit(const int resource);
int maxout_rlimit_nofile(void); int maxout_rlimit_nofile(void);
int maxout_rlimit_fsize(void); int maxout_rlimit_fsize(void);
int setpriority(const int prio);
} }
} }
Loading…
Cancel
Save