diff -Nru cgmanager-0.24/debian/cgmanager.cgmanager.upstart cgmanager-0.24/debian/cgmanager.cgmanager.upstart --- cgmanager-0.24/debian/cgmanager.cgmanager.upstart 2014-03-31 18:49:40.000000000 +0000 +++ cgmanager-0.24/debian/cgmanager.cgmanager.upstart 2014-04-04 22:25:26.000000000 +0000 @@ -2,6 +2,7 @@ author "Serge Hallyn " respawn +expect stop # in trusty /sys/fs/cgroup will be mounted for us. # prior to saucy, we would need to start on mounted @@ -18,6 +19,10 @@ env cgm_extra_mounts="-m name=systemd" pre-start script + # Kill any existing cgproxy. This is required to allow proper + # respawning of cgmanager. + stop cgproxy >/dev/null 2>&1 || true + # check whether we should start a cgproxy or a cgmanager if cgproxy --check-master; then start cgproxy NESTED=yes || true && { stop; exit 0; } @@ -27,5 +32,5 @@ script [ -r /etc/default/cgmanager ] && . /etc/default/cgmanager - exec /sbin/cgmanager $cgmanager_opts $cgm_extra_mounts + exec /sbin/cgmanager --sigstop $cgmanager_opts $cgm_extra_mounts end script diff -Nru cgmanager-0.24/debian/cgmanager.cgproxy.upstart cgmanager-0.24/debian/cgmanager.cgproxy.upstart --- cgmanager-0.24/debian/cgmanager.cgproxy.upstart 2014-03-31 18:49:40.000000000 +0000 +++ cgmanager-0.24/debian/cgmanager.cgproxy.upstart 2014-04-04 22:57:11.000000000 +0000 @@ -2,6 +2,8 @@ author "Serge Hallyn " respawn +expect stop +emits cgmanager-ready # in trusty /sys/fs/cgroup will be mounted for us. # prior to saucy, we would need to start on mounted @@ -16,6 +18,7 @@ pre-start script # check whether we should start if [ -e /proc/self/ns/pid ] && [ "$NESTED" = "no" ]; then + initctl emit -n cgmanager-ready { stop; exit 0; } fi end script @@ -23,5 +26,7 @@ script [ -r /etc/default/cgmanager ] && . /etc/default/cgmanager - exec /sbin/cgproxy $cgmanager_opts + exec /sbin/cgproxy --sigstop $cgmanager_opts end script + +post-start exec initctl emit -n cgmanager-ready diff -Nru cgmanager-0.24/debian/changelog cgmanager-0.24/debian/changelog --- cgmanager-0.24/debian/changelog 2014-04-02 21:20:36.000000000 +0000 +++ cgmanager-0.24/debian/changelog 2014-04-05 01:04:44.000000000 +0000 @@ -1,3 +1,15 @@ +cgmanager (0.24-0ubuntu3) trusty; urgency=medium + + * Use SIGSTOP as a way to tell upstart that we are ready to accept + queries, this fixes a race condition. (LP: #1302174) + * Emit cgmanager-ready once all the required daemons have been spawned + and are ready for requests. (LP: #1302174) + * Always kill cgproxy when spawning cgmanager, this is required to + allow proper restart/respawning on systems using both daemons. + (LP: #1302174) + + -- Stéphane Graber Fri, 04 Apr 2014 21:04:43 -0400 + cgmanager (0.24-0ubuntu2) trusty; urgency=medium [ Serge Hallyn ] diff -Nru cgmanager-0.24/debian/patches/0001-Add-sigstop-support.patch cgmanager-0.24/debian/patches/0001-Add-sigstop-support.patch --- cgmanager-0.24/debian/patches/0001-Add-sigstop-support.patch 1970-01-01 00:00:00.000000000 +0000 +++ cgmanager-0.24/debian/patches/0001-Add-sigstop-support.patch 2014-04-04 22:09:15.000000000 +0000 @@ -0,0 +1,96 @@ +From 061440458d8fcf3983ece16cf4d5f1a0d9d5fee6 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?St=C3=A9phane=20Graber?= +Date: Fri, 4 Apr 2014 13:11:37 -0400 +Subject: [PATCH] Add --sigstop support +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This is used to indicate that the service is ready so that upstart and +possibly some other systems can then have depending services start. + +--daemon does something similar, however calling it prevents log message +from being logged. + +Signed-off-by: Stéphane Graber +Signed-off-by: Serge Hallyn +--- + cgmanager-proxy.c | 5 +++++ + cgmanager.c | 5 +++++ + frontend.c | 1 + + frontend.h | 1 + + 4 files changed, 12 insertions(+) + +diff --git a/cgmanager-proxy.c b/cgmanager-proxy.c +index 075c13f..35d797d 100644 +--- a/cgmanager-proxy.c ++++ b/cgmanager-proxy.c +@@ -948,6 +948,8 @@ out: + static NihOption options[] = { + { 0, "daemon", N_("Detach and run in the background"), + NULL, NULL, &daemonise, NULL }, ++ { 0, "sigstop", N_("Raise SIGSTOP when ready"), ++ NULL, NULL, &sigstop, NULL }, + { 0, "check-master", N_("Check whether cgmanager is running"), + NULL, NULL, &checkmaster, NULL }, + +@@ -1030,6 +1032,9 @@ main (int argc, char *argv[]) + exit(1); + } + ++ if (sigstop) ++ raise(SIGSTOP); ++ + ret = nih_main_loop (); + + /* Destroy any PID file we may have created */ +diff --git a/cgmanager.c b/cgmanager.c +index b3567ff..bb1ba5c 100644 +--- a/cgmanager.c ++++ b/cgmanager.c +@@ -739,6 +739,8 @@ static NihOption options[] = { + NULL, "subsystems to mount", NULL, my_setter }, + { 0, "daemon", N_("Detach and run in the background"), + NULL, NULL, &daemonise, NULL }, ++ { 0, "sigstop", N_("Raise SIGSTOP when ready"), ++ NULL, NULL, &sigstop, NULL }, + + NIH_OPTION_LAST + }; +@@ -884,6 +886,9 @@ main (int argc, char *argv[]) + } + } + ++ if (sigstop) ++ raise(SIGSTOP); ++ + ret = nih_main_loop (); + + /* Destroy any PID file we may have created */ +diff --git a/frontend.c b/frontend.c +index c575d5f..036594c 100644 +--- a/frontend.c ++++ b/frontend.c +@@ -24,6 +24,7 @@ + #include + + int daemonise = FALSE; ++int sigstop = FALSE; + bool setns_pid_supported = false; + unsigned long mypidns; + bool setns_user_supported = false; +diff --git a/frontend.h b/frontend.h +index c8ce4ae..144fd07 100644 +--- a/frontend.h ++++ b/frontend.h +@@ -69,6 +69,7 @@ + **/ + #ifndef __frontend_c + extern int daemonise; ++extern int sigstop; + extern bool setns_pid_supported; + extern unsigned long mypidns; + extern bool setns_user_supported; +-- +1.9.1 + diff -Nru cgmanager-0.24/debian/patches/series cgmanager-0.24/debian/patches/series --- cgmanager-0.24/debian/patches/series 2014-04-02 19:34:38.000000000 +0000 +++ cgmanager-0.24/debian/patches/series 2014-04-04 22:09:43.000000000 +0000 @@ -1 +1,2 @@ makefile-shared +0001-Add-sigstop-support.patch