MCPcopy Create free account
hub / github.com/apache/mesos / set

Function set

src/posix/rlimits.cpp:111–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109
110
111Try<Nothing> set(const RLimitInfo::RLimit& limit)
112{
113 const Try<int> resource = convert(limit.type());
114 if (resource.isError()) {
115 return Error("Could not convert rlimit: " + resource.error());
116 }
117
118 ::rlimit resourceLimit;
119 if (limit.has_soft() && limit.has_hard()) {
120 resourceLimit.rlim_cur = limit.soft();
121 resourceLimit.rlim_max = limit.hard();
122 } else if (!limit.has_soft() && !limit.has_hard()) {
123 resourceLimit.rlim_cur = RLIM_INFINITY;
124 resourceLimit.rlim_max = RLIM_INFINITY;
125 } else {
126 return Error("Invalid rlimit values");
127 }
128
129 if (setrlimit(resource.get(), &resourceLimit) != 0) {
130 return ErrnoError();
131 }
132
133 return Nothing();
134}
135
136
137Try<RLimitInfo::RLimit> get(RLimitInfo::RLimit::Type type)

Callers

nothing calls this directly

Calls 8

ErrnoErrorClass · 0.85
NothingClass · 0.85
typeMethod · 0.80
convertFunction · 0.70
errorMethod · 0.65
ErrorFunction · 0.50
isErrorMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected