This way it can be used from other places as well.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
else
gio_dep = dependency('gio-unix-2.0', version: '>=' + glib_version)
endif
+# GLib event loop race workaround in glibcompat.h, remove when minimum required
+# glib is >= 2.64.0
+glib_crash_workaround = glib_dep.version().version_compare('<2.64.0')
glib_dep = declare_dependency(
dependencies: [ glib_dep, gobject_dep, gio_dep ],
)
--- /dev/null
+#
+# Private symbols specific for pre-2.64.0 GLib workaround
+#
+
+# util/glibcompat.h
+virEventGLibSourceUnrefIdle;
+
+# Let emacs know we want case-insensitive sorting
+# Local Variables:
+# sort-fold-case: t
+# End:
sym_files += 'libvirt_libssh2.syms'
endif
+if glib_crash_workaround
+ used_sym_files += 'libvirt_glib_crash_workaround.syms'
+else
+ sym_files += 'libvirt_glib_crash_workaround.syms'
+endif
+
# variables filled by subdirectories
abort();
return ret;
}
+
+
+/*
+ * If the last reference to a GSource is released in a non-main
+ * thread we're exposed to a race condition that causes a
+ * crash:
+ *
+ * https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1358
+ *
+ * Thus we're using an idle func to release our ref...
+ *
+ * ...but this imposes a significant performance penalty on
+ * I/O intensive workloads which are sensitive to the iterations
+ * of the event loop, so avoid the workaround if we know we have
+ * new enough glib.
+ *
+ * The function below is used from a header file definition.
+ *
+ * Drop when min glib >= 2.64.0
+ */
+#if GLIB_CHECK_VERSION(2, 64, 0) != TRUE
+
+gboolean
+virEventGLibSourceUnrefIdle(gpointer data)
+{
+ GSource *src = data;
+
+ g_source_unref(src);
+
+ return FALSE;
+}
+
+#endif
#define g_canonicalize_filename vir_g_canonicalize_filename
#undef g_fsync
#define g_fsync vir_g_fsync
+
+/* Drop when min glib >= 2.64.0 */
+#if GLIB_CHECK_VERSION(2, 64, 0)
+# define g_vir_source_unref_safe(source) g_source_unref(source)
+#else
+# define g_vir_source_unref_safe(source) g_idle_add(virEventGLibSourceUnrefIdle, source)
+
+gboolean
+virEventGLibSourceUnrefIdle(gpointer data);
+
+#endif
return NULL;
}
-/*
- * If the last reference to a GSource is released in a non-main
- * thread we're exposed to a race condition that causes a
- * crash:
- *
- * https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1358
- *
- * Thus we're using an idle func to release our ref...
- *
- * ...but this imposes a significant performance penalty on
- * I/O intensive workloads which are sensitive to the iterations
- * of the event loop, so avoid the workaround if we know we have
- * new enough glib.
- */
-#if GLIB_CHECK_VERSION(2, 64, 0)
-# define g_vir_source_unref_safe(source) g_source_unref(source)
-#else
-# define g_vir_source_unref_safe(source) g_idle_add(virEventGLibSourceUnrefIdle, source)
-
-static gboolean
-virEventGLibSourceUnrefIdle(gpointer data)
-{
- GSource *src = data;
-
- g_source_unref(src);
-
- return FALSE;
-}
-#endif
-
static void
virEventGLibHandleUpdate(int watch,