diff -Nru libcgroup-0.37.1/debian/changelog libcgroup-0.37.1/debian/changelog --- libcgroup-0.37.1/debian/changelog 2011-08-11 11:52:07.000000000 -0500 +++ libcgroup-0.37.1/debian/changelog 2011-08-16 18:16:41.000000000 -0500 @@ -1,3 +1,10 @@ +libcgroup (0.37.1-1ubuntu5) oneiric; urgency=low + + * debian/patches/fix-cgclear-failures.patch: fix race conditions in + cgclear. (LP: #827279) + + -- Serge Hallyn Tue, 16 Aug 2011 18:15:58 -0500 + libcgroup (0.37.1-1ubuntu4) oneiric; urgency=low * Shell syntax fixes in cgconfig.conf diff -Nru libcgroup-0.37.1/debian/patches/fix-cgclear-failures.patch libcgroup-0.37.1/debian/patches/fix-cgclear-failures.patch --- libcgroup-0.37.1/debian/patches/fix-cgclear-failures.patch 1969-12-31 18:00:00.000000000 -0600 +++ libcgroup-0.37.1/debian/patches/fix-cgclear-failures.patch 2011-08-16 18:15:53.000000000 -0500 @@ -0,0 +1,59 @@ +Description: Fix race conditions in cgclear which can make 'stop cgconfig' fail + If a task exits after cgclear starts but before it has reclassified it, + don't return an error. Also, if a task has been created during that time, + then we simply need to re-start the reclassification loop. +Author: Serge Hallyn +Forwarded: no +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libcgroup/+bug/827279 + +Index: libcgroup-0.37.1/src/api.c +=================================================================== +--- libcgroup-0.37.1.orig/src/api.c 2011-08-16 18:10:59.833551136 -0500 ++++ libcgroup-0.37.1/src/api.c 2011-08-16 18:12:40.583549430 -0500 +@@ -1671,15 +1671,24 @@ + break; + + ret = fprintf(output_tasks, "%d", tids); +- if (ret < 0) +- break; ++ if (ret < 0) { ++ if (errno != ESRCH) ++ break; ++ // the task just went away, ignore it ++ ret = 0; ++ continue; ++ } + + /* + * Flush the file, we need only one process per write() call. + */ + ret = fflush(output_tasks); +- if (ret < 0) +- break; ++ if (ret < 0 ) { ++ if (errno != ESRCH) ++ break; ++ // the task just went away, ignore it ++ ret = 0 ; ++ } + } + + if (ret < 0) { +@@ -1715,6 +1724,7 @@ + + cgroup_dbg("Removing group %s:%s\n", controller, cgroup_name); + ++again: + /* + * Open tasks file of the group to delete. + */ +@@ -1748,6 +1758,9 @@ + + ret = rmdir(path); + if (ret != 0 && errno != ENOENT) { ++ if (errno == EBUSY) ++ // more tasks have come up ++ goto again; + last_errno = errno; + return ECGOTHER; + } diff -Nru libcgroup-0.37.1/debian/patches/series libcgroup-0.37.1/debian/patches/series --- libcgroup-0.37.1/debian/patches/series 2011-08-11 11:50:57.000000000 -0500 +++ libcgroup-0.37.1/debian/patches/series 2011-08-16 18:10:55.000000000 -0500 @@ -13,3 +13,4 @@ 0013-Fix-spelling-mistake-in-cgcreate.patch debian-changes-0.37.1-1ubuntu1 mount-freezer.patch +fix-cgclear-failures.patch