From ee7fbc954ec6ca4f85e384083f8065271147f53e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 26 Apr 2020 15:46:53 +0200 Subject: [PATCH] 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(). --- shared/nm-glib-aux/nm-glib.h | 8 ++++++++ 1 file changed, 8 insertions(+) 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__ */