[libsoup] Detect if libsoup2 is loaded in the same process at init
- From: Patrick Griffis <pgriffis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] Detect if libsoup2 is loaded in the same process at init
- Date: Tue, 16 Nov 2021 16:20:45 +0000 (UTC)
commit 9596a869414bb0811f1e1f6009c950ca7af81189
Author: Patrick Griffis <pgriffis igalia com>
Date: Tue Nov 16 10:20:02 2021 -0600
Detect if libsoup2 is loaded in the same process at init
Closes #211
libsoup/soup-init.c | 19 +++++++++++++++++++
meson.build | 4 +++-
2 files changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/libsoup/soup-init.c b/libsoup/soup-init.c
index 816c9ae9..8a33c77d 100644
--- a/libsoup/soup-init.c
+++ b/libsoup/soup-init.c
@@ -10,6 +10,7 @@
#endif
#include <glib/gi18n-lib.h>
+#include <gmodule.h>
#include "gconstructor.h"
#ifdef G_OS_WIN32
@@ -19,6 +20,21 @@
HMODULE soup_dll;
#endif
+static gboolean
+soup2_is_loaded (void)
+{
+ GModule *module = g_module_open (NULL, 0);
+ gpointer func;
+ gboolean result = FALSE;
+
+ if (g_module_symbol (module, "soup_uri_new", &func))
+ result = TRUE;
+
+ g_module_close (module);
+
+ return result;
+}
+
static void
soup_init (void)
{
@@ -34,6 +50,9 @@ soup_init (void)
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif
+
+ if (soup2_is_loaded ())
+ g_error ("libsoup2 symbols detected. Using libsoup2 and libsoup3 in the same process is not
supported.");
}
#if defined (G_OS_WIN32)
diff --git a/meson.build b/meson.build
index 8fabd754..b07bce1e 100644
--- a/meson.build
+++ b/meson.build
@@ -99,12 +99,14 @@ add_project_arguments(common_flags, language : 'c')
glib_required_version = '>= 2.69.1'
glib_dep = dependency('glib-2.0', version : glib_required_version,
fallback: ['glib', 'libglib_dep'])
+gmodule_dep = dependency('gmodule-2.0', version : glib_required_version,
+ fallback: ['glib', 'libgmodule_dep'])
gobject_dep = dependency('gobject-2.0', version : glib_required_version,
fallback: ['glib', 'libgobject_dep'])
gio_dep = dependency('gio-2.0', version : glib_required_version,
fallback: ['glib', 'libgio_dep'])
-glib_deps = [glib_dep, gobject_dep, gio_dep]
+glib_deps = [glib_dep, gmodule_dep, gobject_dep, gio_dep]
libnghttp2_dep = dependency('libnghttp2')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]