summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-04-26 15:46:53 +0200
committerThomas Haller <thaller@redhat.com>2020-04-28 18:35:59 +0200
commitee7fbc954ec6ca4f85e384083f8065271147f53e (patch)
tree4df06bdbeb50037584beb9fcae40c348657bddc4
parent32664c72a5a61e1b2a156436d9132cbbc928b9c0 (diff)
downloadNetworkManager-ee7fbc954ec6ca4f85e384083f8065271147f53e.tar.gz
shared/glib: prevent users to use g_cancellable_reset()
When handling a GCancellable, you make decisions based on when the cancelled property of a GCancellable changes. Correctly handling a cancellable becoming uncancelled again is really complicated, nor is it clear what it even means: should the flipping be treated as cancellation or not? Probably if the cancelled property gets reset, you already start aborting and there is no way back. So, you would want that a cancellation is always handled. But it's hard to implement that correctly, and it's odd to claim something was cancelled, if g_cancellable_is_cancelled() doesn't agree (anymore). Avoid such problems by preventing users to call g_cancellable_reset().
-rw-r--r--shared/nm-glib-aux/nm-glib.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/shared/nm-glib-aux/nm-glib.h b/shared/nm-glib-aux/nm-glib.h
index 4ecba9ffca..7a5b8edd7d 100644
--- a/shared/nm-glib-aux/nm-glib.h
+++ b/shared/nm-glib-aux/nm-glib.h
@@ -622,4 +622,12 @@ g_hash_table_steal_extended (GHashTable *hash_table,
/*****************************************************************************/
+__attribute__((__deprecated__("Don't use g_cancellable_reset(). Create a new cancellable instead.")))
+void _nm_g_cancellable_reset (GCancellable *cancellable);
+
+#undef g_cancellable_reset
+#define g_cancellable_reset(cancellable) _nm_g_cancellable_reset(cancellable)
+
+/*****************************************************************************/
+
#endif /* __NM_GLIB_H__ */