[glib-networking] openssl: Port to the new GIO module API



commit ac7031c971016b899602b83da64b81fa18ab412d
Author: Nirbheek Chauhan <nirbheek centricular com>
Date:   Wed Feb 20 20:24:57 2019 +0530

    openssl: Port to the new GIO module API
    
    This API is available since GLib 2.55.1 and allows static linking of
    multiple different modules. All other glib-networking modules already
    use this API.
    
    See: https://bugzilla.gnome.org/show_bug.cgi?id=684282

 meson.build                       |  6 ------
 tls/openssl/gtlsbackend-openssl.c |  8 ++++++--
 tls/openssl/meson.build           |  1 -
 tls/openssl/openssl-module.c      | 12 ++++++------
 4 files changed, 12 insertions(+), 15 deletions(-)
---
diff --git a/meson.build b/meson.build
index f0697e9..69cd18c 100644
--- a/meson.build
+++ b/meson.build
@@ -42,12 +42,6 @@ if host_system.contains('linux')
   module_ldflags += cc.get_supported_link_arguments(test_ldflag)
 endif
 
-extra_args= []
-# Detect and set symbol visibility
-if cc.get_id() == 'msvc'
-  extra_args += ['-D_GLIB_EXTERN=__declspec (dllexport) extern']
-endif
-
 # *** Check GLib GIO        ***
 glib_dep = dependency('glib-2.0', version: '>= 2.55.1',
   fallback: ['glib', 'libglib_dep'])
diff --git a/tls/openssl/gtlsbackend-openssl.c b/tls/openssl/gtlsbackend-openssl.c
index 96428ac..abff7bb 100644
--- a/tls/openssl/gtlsbackend-openssl.c
+++ b/tls/openssl/gtlsbackend-openssl.c
@@ -119,6 +119,7 @@ static gpointer
 gtls_openssl_init (gpointer data)
 {
   int i;
+  GTypePlugin *plugin;
 
   /* Initialize openssl threading */
   mutex_array = g_malloc_n (CRYPTO_num_locks(), sizeof (GMutex));
@@ -136,8 +137,9 @@ gtls_openssl_init (gpointer data)
   OpenSSL_add_all_algorithms ();
 
   /* Leak the module to keep it from being unloaded. */
-  g_type_plugin_use (g_type_get_plugin (G_TYPE_TLS_BACKEND_OPENSSL));
-
+  plugin = g_type_get_plugin (G_TYPE_TLS_BACKEND_OPENSSL);
+  if (plugin != NULL)
+    g_type_plugin_use (plugin);
   return NULL;
 }
 
@@ -289,6 +291,8 @@ void
 g_tls_backend_openssl_register (GIOModule *module)
 {
   g_tls_backend_openssl_register_type (G_TYPE_MODULE (module));
+  if (!module)
+    g_io_extension_point_register (G_TLS_BACKEND_EXTENSION_POINT_NAME);
   g_io_extension_point_implement (G_TLS_BACKEND_EXTENSION_POINT_NAME,
                                   g_tls_backend_openssl_get_type(),
                                   "openssl",
diff --git a/tls/openssl/meson.build b/tls/openssl/meson.build
index 6684007..c1f4d31 100644
--- a/tls/openssl/meson.build
+++ b/tls/openssl/meson.build
@@ -32,7 +32,6 @@ module = shared_module(
   name_suffix: module_suffix,
   install: true,
   install_dir: gio_module_dir,
-  c_args: extra_args
 )
 
 if get_option('static_modules')
diff --git a/tls/openssl/openssl-module.c b/tls/openssl/openssl-module.c
index 39b60cd..3b6c84c 100644
--- a/tls/openssl/openssl-module.c
+++ b/tls/openssl/openssl-module.c
@@ -30,8 +30,8 @@
 #include "gtlsbackend-openssl.h"
 
 
-void
-g_io_module_load (GIOModule *module)
+G_MODULE_EXPORT void
+g_io_openssl_load (GIOModule *module)
 {
   gchar *locale_dir;
 #ifdef G_OS_WIN32
@@ -53,13 +53,13 @@ g_io_module_load (GIOModule *module)
   g_free (locale_dir);
 }
 
-void
-g_io_module_unload (GIOModule *module)
+G_MODULE_EXPORT void
+g_io_openssl_unload (GIOModule *module)
 {
 }
 
-gchar **
-g_io_module_query (void)
+G_MODULE_EXPORT gchar **
+g_io_openssl_query (void)
 {
   return g_strsplit (G_TLS_BACKEND_EXTENSION_POINT_NAME, "!", -1);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]