]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
Fix cgroup_modify_cgroup gratuitous failure
authorGlauber Costa <glommer@parallels.com>
Fri, 27 Jul 2012 10:55:55 +0000 (12:55 +0200)
committerIvana Hutarova Varekova <varekova@redhat.com>
Fri, 27 Jul 2012 10:55:55 +0000 (12:55 +0200)
commit64d054a62a3deb2be8d0b93e51282aa8c227eb5c
tree1fb894952ec8bac3b950f2685fbdfc8c65054b83
parenta08bd3c2e7bbdaecc3a99f48cf20176a1316e5ff
Fix cgroup_modify_cgroup gratuitous failure

Around one year ago, the following was reported:
http://comments.gmane.org/gmane.comp.lib.libcg.devel/3116 (Error when
calling cgroup_modify_cgroup())

I ran into the very same error. Inspecting the code in libcg, it seemed
to me that the best thing to avoid that is to never attempt to write
something the user never wrote to.

That is because if the user actually tries to write to a read-only file,
we should yield an error, making skipping read-only a bad solution.

My solution is to add a field to the value structure indicating whether
or not it is dirty. That value will indicate whether or not an error in
the write-to-filesystem routine is considered fatal or not.  Non-dirty
values will still be written, but their failures are not considered
fatal. cgroup_modify_cgroup then becomes a simple flusher, and the
problem goes away.

[ v2: Also mark dirty value writes using cgroup_set_value_* ]
[ v3: fail if write fails only for dirty values ]

Signed-off-by: Glauber Costa <glommer@parallels.com>
src/api.c
src/libcgroup-internal.h
src/wrapper.c