diff options
| author | Michael Biebl <biebl@debian.org> | 2022-03-23 11:52:46 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2022-03-23 11:52:46 +0100 |
| commit | 024ee2bf31c1c57823c8bf6588714a4ede5baed1 (patch) | |
| tree | 5fd63275acf48411b17c71c92771267359ba95d6 /src/libnm-glib-aux | |
| parent | 0514770b02f34ccb56b6bc52010452663c6717ed (diff) | |
| parent | 8c623dddbdebe354cb94bfc559a5371a14865317 (diff) | |
Update upstream source from tag 'upstream/1.36.4'
Update to upstream version '1.36.4' with Debian dir 64567d8bf986e0827368a9989323ba0356fe2888
Diffstat (limited to 'src/libnm-glib-aux')
| -rw-r--r-- | src/libnm-glib-aux/nm-shared-utils.c | 20 | ||||
| -rw-r--r-- | src/libnm-glib-aux/nm-shared-utils.h | 4 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/libnm-glib-aux/nm-shared-utils.c b/src/libnm-glib-aux/nm-shared-utils.c index 6e6fed12..563b7cc2 100644 --- a/src/libnm-glib-aux/nm-shared-utils.c +++ b/src/libnm-glib-aux/nm-shared-utils.c @@ -6680,3 +6680,23 @@ nm_g_main_context_iterate_for_msec(GMainContext *context, guint timeout_msec) while (source) g_main_context_iteration(context, TRUE); } + +/*****************************************************************************/ + +gboolean +nm_g_main_context_can_acquire(GMainContext *context) +{ + /* Fast path. Usually we don't pass contexts between threads + * and operate while iterating the context. Hence, usually we + * already acquired the context. Check that first. */ + if (g_main_context_is_owner(context)) + return TRUE; + + /* Either the context is not owned, or owned by somebody else. Only + * one way to find out. */ + if (!g_main_context_acquire(context)) + return FALSE; + + g_main_context_release(context); + return TRUE; +} diff --git a/src/libnm-glib-aux/nm-shared-utils.h b/src/libnm-glib-aux/nm-shared-utils.h index 54550f27..a953140b 100644 --- a/src/libnm-glib-aux/nm-shared-utils.h +++ b/src/libnm-glib-aux/nm-shared-utils.h @@ -1789,7 +1789,7 @@ nm_g_idle_add_source(GSourceFunc func, gpointer user_data) /* A convenience function to attach a new timeout source to the default GMainContext. * In that sense it's very similar to g_idle_add() except that it returns a * reference to the new source. */ - return nm_g_source_attach(nm_g_idle_source_new(G_PRIORITY_DEFAULT, func, user_data, NULL), + return nm_g_source_attach(nm_g_idle_source_new(G_PRIORITY_DEFAULT_IDLE, func, user_data, NULL), NULL); } @@ -1931,6 +1931,8 @@ nm_g_main_context_iterate_ready(GMainContext *context) void nm_g_main_context_iterate_for_msec(GMainContext *context, guint timeout_msec); +gboolean nm_g_main_context_can_acquire(GMainContext *context); + /*****************************************************************************/ static inline int |