Skip to content

Commit 3ff39e8

Browse files
committed
Add handler for GIO modules
This creates a GIO modules cache from all installed GIO modules. If this isn't present then Glib2 code needs to start each module even if it doesn't need it, and in certain circumstances this can cause issues. For instance, GTK2 apps had a startup delay due to a DBUS timeout caused by the DBUS connection leaking between modules and being closed in one module while another still depended on it. Reference: getsolus/packages#540 Signed-off-by: Reilly Brogan <reilly@reillybrogan.com>
1 parent 3260635 commit 3ff39e8

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

src/context.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ static const UscHandler *usc_handlers[] = {
7676

7777
/** Enter userspace. */
7878
&usc_handler_glib2,
79+
&usc_handler_glib2_gio,
7980
&usc_handler_gdk_pixbuf,
8081
&usc_handler_fonts,
8182
&usc_handler_mime,

src/handlers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ extern UscHandler usc_handler_apparmor;
5151
#endif
5252

5353
extern UscHandler usc_handler_glib2;
54+
extern UscHandler usc_handler_glib2_gio;
5455
extern UscHandler usc_handler_gdk_pixbuf;
5556
extern UscHandler usc_handler_fonts;
5657
extern UscHandler usc_handler_mime;

src/handlers/xdg/glib2-gio.c

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* This file is part of usysconf.
3+
*
4+
* Copyright © 2017-2019 Solus Project
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*/
11+
12+
#define _GNU_SOURCE
13+
14+
#include "context.h"
15+
#include "files.h"
16+
#include "util.h"
17+
18+
static const char *gio_modules_paths[] = {
19+
"/usr/lib64/gio/modules/",
20+
};
21+
22+
/**
23+
* Create a module cache with metadata from gio modules. Without this gio has to open each module which can cause bugs.
24+
*/
25+
static UscHandlerStatus usc_handler_glib2_gio_exec(__usc_unused__ UscContext *ctx, const char *path)
26+
{
27+
autofree(char) *fp = NULL;
28+
char *command[] = {
29+
"/usr/bin/gio-querymodules",
30+
NULL, /* /usr/lib64/gio/modules */
31+
NULL, /* Terminator */
32+
};
33+
34+
if (!usc_file_is_dir(path)) {
35+
return USC_HANDLER_SKIP;
36+
}
37+
38+
command[1] = (char *)path,
39+
40+
usc_context_emit_task_start(ctx, "Creating GIO modules cache");
41+
int ret = usc_exec_command(command);
42+
if (ret != 0) {
43+
usc_context_emit_task_finish(ctx, USC_HANDLER_FAIL);
44+
return USC_HANDLER_FAIL | USC_HANDLER_BREAK;
45+
}
46+
usc_context_emit_task_finish(ctx, USC_HANDLER_SUCCESS);
47+
/* Only want to run once for all of our globs */
48+
return USC_HANDLER_SUCCESS | USC_HANDLER_BREAK;
49+
}
50+
51+
const UscHandler usc_handler_glib2_gio = {
52+
.name = "glib2-gio",
53+
.description = "Create glib2 GIO modules cache",
54+
.required_bin = "/usr/bin/gio-querymodules",
55+
.exec = usc_handler_glib2_gio_exec,
56+
.paths = gio_modules_paths,
57+
.n_paths = ARRAY_SIZE(gio_modules_paths),
58+
};
59+
60+
/*
61+
* Editor modelines - https://www.wireshark.org/tools/modelines.html
62+
*
63+
* Local variables:
64+
* c-basic-offset: 8
65+
* tab-width: 8
66+
* indent-tabs-mode: nil
67+
* End:
68+
*
69+
* vi: set shiftwidth=8 tabstop=8 expandtab:
70+
* :indentSize=8:tabSize=8:noTabs=true:
71+
*/

src/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ xdg_handlers = [
33
'gconf',
44
'gdk-pixbuf',
55
'glib2',
6+
'glib2-gio',
67
'mime',
78
'icon-cache',
89
'fonts',

0 commit comments

Comments
 (0)