Fixes/issue28 #38

Merged
merged 2 commits into from Mar 19, 2013
Jump to file or symbol
Failed to load files and symbols.
+14 −5
Split
View
@@ -104,6 +104,12 @@ local function create_group(proc, prefix, mapping, subsys)
else
path = name
end
+
+ local rv = CGroup.get_group(subsys .."/".. path)
+ if rv then
+ return rv
+ end
+
rv = CGroup.new(path, mapping.param, subsys)
if mapping.adjust then
rv.adjust[#rv.adjust+1] = mapping.adjust
View
@@ -409,12 +409,9 @@ end
ulatency.add_timeout(cgroups_cleanup, 120000)
+--! @brief create and initialize new cgroup in _CGroup_Cache, already existing cgroup is replaced
function CGroup.new(name, init, tree)
tree = tree or "cpu"
- rv = _CGroup_Cache[tree..'/'..name]
- if rv then
- return rv
- end
if CGROUP_DEFAULT[tree] then
cinit = table.copy(CGROUP_DEFAULT[tree])
else
@@ -431,8 +428,14 @@ function CGroup.get_groups()
return _CGroup_Cache
end
+--! @brief return cgroup or false/nil if it does not exists or is not present in ulatency internal _CGroup_Cache
function CGroup.get_group(name)
- return _CGroup_Cache[name]
+ local cgr = _CGroup_Cache[name]
+ if cgr then
+ local stat=posix.stat(cgr:path())
+ return (stat and stat.type == 'directory') and cgr or nil
+ end
+ return nil
end