Merge lp:~xnox/ubuntu-app-launch/drop-cgmanager into lp:ubuntu-app-launch

Proposed by Dimitri John Ledkov
Status: Approved
Approved by: Sebastien Bacher
Approved revision: 317
Proposed branch: lp:~xnox/ubuntu-app-launch/drop-cgmanager
Merge into: lp:ubuntu-app-launch
Diff against target: 256 lines (+0/-207)
4 files modified
CMakeLists.txt (+0/-3)
debian/control (+0/-1)
libubuntu-app-launch/utils-shared.c (+0/-197)
libubuntu-app-launch/utils.h (+0/-6)
To merge this branch: bzr merge lp:~xnox/ubuntu-app-launch/drop-cgmanager
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
Ubuntu Desktop Pending
Indicator Applet Developers Pending
Review via email: mp+323033@code.launchpad.net

Commit message

Drop cgmanager, not used since upstart code was dropped.

Description of the change

Drop cgmanager, not used since upstart code was dropped.

To post a comment you must log in.
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Hello? Are merge proposals being reviewed at all?

Revision history for this message
Sebastien Bacher (seb128) wrote :

go for it

review: Approve

Unmerged revisions

317. By Dimitri John Ledkov

Drop cgmanager, not used since upstart code was dropped.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2017-03-20 10:13:50 +0000
+++ CMakeLists.txt 2017-04-24 12:41:34 +0000
@@ -85,9 +85,6 @@
85pkg_check_modules(LTTNG REQUIRED lttng-ust)85pkg_check_modules(LTTNG REQUIRED lttng-ust)
86include_directories(${LTTNG_INCLUDE_DIRS})86include_directories(${LTTNG_INCLUDE_DIRS})
8787
88pkg_check_modules(CGMANAGER REQUIRED libcgmanager)
89include_directories(${CGMANAGER_INCLUDE_DIRS})
90
91pkg_check_modules(MIR REQUIRED mirclient)88pkg_check_modules(MIR REQUIRED mirclient)
92include_directories(${MIR_INCLUDE_DIRS})89include_directories(${MIR_INCLUDE_DIRS})
9390
9491
=== modified file 'debian/control'
--- debian/control 2017-03-28 13:45:10 +0000
+++ debian/control 2017-04-24 12:41:34 +0000
@@ -9,7 +9,6 @@
9 dbus-test-runner,9 dbus-test-runner,
10 debhelper (>= 9),10 debhelper (>= 9),
11 googletest | google-mock,11 googletest | google-mock,
12 libcgmanager-dev,
13 libcurl4-dev | libcurl4-gnutls-dev,12 libcurl4-dev | libcurl4-gnutls-dev,
14 libdbus-1-dev,13 libdbus-1-dev,
15 libdbustest1-dev (>= 14.04.0),14 libdbustest1-dev (>= 14.04.0),
1615
=== modified file 'libubuntu-app-launch/utils-shared.c'
--- libubuntu-app-launch/utils-shared.c 2017-02-22 22:50:19 +0000
+++ libubuntu-app-launch/utils-shared.c 2017-04-24 12:41:34 +0000
@@ -19,7 +19,6 @@
1919
20#include "utils.h"20#include "utils.h"
21#include <gio/gio.h>21#include <gio/gio.h>
22#include <cgmanager/cgmanager.h>
2322
24#include "ual-tracepoint.h"23#include "ual-tracepoint.h"
2524
@@ -97,202 +96,6 @@
97 return keyfile;96 return keyfile;
98}97}
9998
100/* Structure to handle data for the cgmanager connection
101 set of callbacks */
102typedef struct {
103 GMainLoop * loop;
104 GCancellable * cancel;
105 GDBusConnection * con;
106} cgm_connection_t;
107
108/* Function that gets executed when we timeout trying to connect. This
109 is related to: LP #1377332 */
110static gboolean
111cgroup_manager_connection_timeout_cb (gpointer data)
112{
113 cgm_connection_t * connection = (cgm_connection_t *)data;
114
115 g_cancellable_cancel(connection->cancel);
116
117 return G_SOURCE_CONTINUE;
118}
119
120static void
121cgroup_manager_connection_core_cb (GDBusConnection *(*finish_func)(GAsyncResult * res, GError ** error), GAsyncResult * res, cgm_connection_t * connection)
122{
123 GError * error = NULL;
124
125 connection->con = finish_func(res, &error);
126
127 if (error != NULL) {
128 g_warning("Unable to get cgmanager connection: %s", error->message);
129 g_error_free(error);
130 }
131
132 g_main_loop_quit(connection->loop);
133}
134
135static void
136cgroup_manager_connection_bus_cb (GObject * obj, GAsyncResult * res, gpointer data)
137{
138 cgroup_manager_connection_core_cb(g_bus_get_finish, res, (cgm_connection_t *)data);
139}
140
141static void
142cgroup_manager_connection_addr_cb (GObject * obj, GAsyncResult * res, gpointer data)
143{
144 cgroup_manager_connection_core_cb(g_dbus_connection_new_for_address_finish, res, (cgm_connection_t *)data);
145}
146
147G_DEFINE_QUARK(CGMANAGER_CONTEXT, cgmanager_context)
148
149/* Get the connection to the cgroup manager */
150GDBusConnection *
151cgroup_manager_connection (void)
152{
153 gboolean use_session_bus = g_getenv("UBUNTU_APP_LAUNCH_CG_MANAGER_SESSION_BUS") != NULL;
154 GMainContext * context = g_main_context_new();
155 g_main_context_push_thread_default(context);
156
157 cgm_connection_t connection = {
158 .loop = g_main_loop_new(context, FALSE),
159 .con = NULL,
160 .cancel = g_cancellable_new()
161 };
162
163 GSource * timesrc = g_timeout_source_new_seconds(1);
164 g_source_set_callback(timesrc, cgroup_manager_connection_timeout_cb, &connection, NULL);
165 g_source_attach(timesrc, context);
166
167 if (use_session_bus) {
168 /* For working dbusmock */
169 g_debug("Connecting to CG Manager on session bus");
170 g_bus_get(G_BUS_TYPE_SESSION,
171 connection.cancel,
172 cgroup_manager_connection_bus_cb,
173 &connection);
174 } else {
175 g_dbus_connection_new_for_address(
176 CGMANAGER_DBUS_PATH,
177 G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
178 NULL, /* Auth Observer */
179 connection.cancel, /* Cancellable */
180 cgroup_manager_connection_addr_cb,
181 &connection);
182 }
183
184 g_main_loop_run(connection.loop);
185
186 g_source_destroy(timesrc);
187 g_source_unref(timesrc);
188
189 g_main_loop_unref(connection.loop);
190 g_object_unref(connection.cancel);
191
192 g_main_context_pop_thread_default(context);
193
194 if (!use_session_bus && connection.con != NULL) {
195 g_object_set_qdata(G_OBJECT(connection.con),
196 cgmanager_context_quark(),
197 context);
198 } else {
199 g_main_context_unref(context);
200 }
201
202 return connection.con;
203}
204
205/* This does a complex unref for the case that we're not using a shared
206 pointer. In that case the initialization happens under the context that
207 we used for the timeout, and it turns out GDBus saves that context to
208 use for the close event. Upon the task closing it sends an idle source
209 to that context which free's the last bit of memory. So we need the events
210 on that context to be executed or we just leak. So what this does is force
211 a close synchronously so that the event gets placed on the context and then
212 frees the context to ensure that all of the events are processed. */
213void
214cgroup_manager_unref (GDBusConnection * cgmanager)
215{
216 if (cgmanager == NULL)
217 return;
218
219 GMainContext * creationcontext = g_object_get_qdata(G_OBJECT(cgmanager), cgmanager_context_quark());
220 if (creationcontext == NULL) {
221 g_object_unref(cgmanager);
222 return;
223 }
224
225 GError * error = NULL;
226 g_dbus_connection_close_sync(cgmanager, NULL, &error);
227
228 if (error != NULL) {
229 g_warning("Unable to close CGManager Connection: %s", error->message);
230 g_error_free(error);
231 }
232
233 g_object_unref(cgmanager);
234
235 while (g_main_context_pending(creationcontext)) {
236 g_main_context_iteration(creationcontext, TRUE /* may block */);
237 }
238
239 g_main_context_unref(creationcontext);
240}
241
242/* Get the PIDs for a particular cgroup */
243/* We're using the base cgroup 'freezer' in this code (and
244 in the Upstart jobs). Really the actual group is meaningless
245 we just need one that is in every kernel we need to support.
246 We're just using the cgroup as a bag of PIDs, not for
247 restricting any particular resource. */
248GList *
249pids_from_cgroup (GDBusConnection * cgmanager, const gchar * jobname, const gchar * instancename)
250{
251 GError * error = NULL;
252 const gchar * name = g_getenv("UBUNTU_APP_LAUNCH_CG_MANAGER_NAME");
253 gchar * groupname = NULL;
254 if (jobname != NULL) {
255 groupname = g_strdup_printf("upstart/%s-%s", jobname, instancename);
256 }
257
258 g_debug("Looking for cg manager '%s' group '%s'", name, groupname);
259
260 GVariant * vtpids = g_dbus_connection_call_sync(cgmanager,
261 name, /* bus name for direct connection is NULL */
262 "/org/linuxcontainers/cgmanager",
263 "org.linuxcontainers.cgmanager0_0",
264 "GetTasksRecursive",
265 g_variant_new("(ss)", "freezer", groupname ? groupname : ""),
266 G_VARIANT_TYPE("(ai)"),
267 G_DBUS_CALL_FLAGS_NONE,
268 -1, /* default timeout */
269 NULL, /* cancellable */
270 &error);
271
272 g_free(groupname);
273
274 if (error != NULL) {
275 g_warning("Unable to get PID list from cgroup manager: %s", error->message);
276 g_error_free(error);
277 return NULL;
278 }
279
280 GVariant * vpids = g_variant_get_child_value(vtpids, 0);
281 GVariantIter iter;
282 g_variant_iter_init(&iter, vpids);
283 gint32 pid;
284 GList * retval = NULL;
285
286 while (g_variant_iter_loop(&iter, "i", &pid)) {
287 retval = g_list_prepend(retval, GINT_TO_POINTER(pid));
288 }
289
290 g_variant_unref(vpids);
291 g_variant_unref(vtpids);
292
293 return retval;
294}
295
296/* Global markers for the ual_tracepoint macro */99/* Global markers for the ual_tracepoint macro */
297int _ual_tracepoints_env_checked = 0;100int _ual_tracepoints_env_checked = 0;
298int _ual_tracepoints_enabled = 0;101int _ual_tracepoints_enabled = 0;
299102
=== modified file 'libubuntu-app-launch/utils.h'
--- libubuntu-app-launch/utils.h 2017-03-15 14:05:17 +0000
+++ libubuntu-app-launch/utils.h 2017-04-24 12:41:34 +0000
@@ -38,12 +38,6 @@
38 int timeout_s);38 int timeout_s);
39void starting_handshake_wait (handshake_t * handshake);39void starting_handshake_wait (handshake_t * handshake);
4040
41GDBusConnection * cgroup_manager_connection (void);
42void cgroup_manager_unref (GDBusConnection * cgroup_manager);
43GList * pids_from_cgroup (GDBusConnection * cgmanager,
44 const gchar * jobname,
45 const gchar * instancename);
46
47gboolean verify_keyfile (GKeyFile * inkeyfile,41gboolean verify_keyfile (GKeyFile * inkeyfile,
48 const gchar * desktop);42 const gchar * desktop);
4943

Subscribers

People subscribed via source and target branches