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

Subscribers

People subscribed via source and target branches