diff options
author | Thomas Haller <thaller@redhat.com> | 2022-02-18 13:25:13 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-02-24 09:38:53 +0100 |
commit | 8bb85aecdac3cdb4fa3f09c6e053d4b99c29e04a (patch) | |
tree | f9ce15dae7aa70e46c3adc3f133f6720e0ca09e8 | |
parent | 32a828080c2072d2494df6be64ddaba0c4801f00 (diff) | |
download | NetworkManager-8bb85aecdac3cdb4fa3f09c6e053d4b99c29e04a.tar.gz |
core: add NM_SHUTDOWN_TIMEOUT_1500_MSEC macro
When you have an async operation, you must make sure that
it is cancellable or completes in at most NM_SHUTDOWN_TIMEOUT_MAX_MSEC.
But NM_SHUTDOWN_TIMEOUT_MAX_MSEC leaves it undefined how long it is.
If you really want to wait for 1500msec, but also need to ensure
to stay within NM_SHUTDOWN_TIMEOUT_MAX_MSEC, then use
NM_SHUTDOWN_TIMEOUT_1500_MSEC. This has the semantic of guaranteeing
both.
-rw-r--r-- | src/core/NetworkManagerUtils.c | 4 | ||||
-rw-r--r-- | src/core/NetworkManagerUtils.h | 11 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/core/NetworkManagerUtils.c b/src/core/NetworkManagerUtils.c index c4df566eab..2f30bcaa39 100644 --- a/src/core/NetworkManagerUtils.c +++ b/src/core/NetworkManagerUtils.c @@ -34,6 +34,10 @@ /*****************************************************************************/ +G_STATIC_ASSERT(NM_SHUTDOWN_TIMEOUT_1500_MSEC <= NM_SHUTDOWN_TIMEOUT_MAX_MSEC); + +/*****************************************************************************/ + /** * nm_utils_get_shared_wifi_permission: * @connection: the NMConnection to lookup the permission. diff --git a/src/core/NetworkManagerUtils.h b/src/core/NetworkManagerUtils.h index 465f19b80f..fce940073b 100644 --- a/src/core/NetworkManagerUtils.h +++ b/src/core/NetworkManagerUtils.h @@ -121,6 +121,17 @@ NMPlatformRoutingRule *nm_ip_routing_rule_to_platform(const NMIPRoutingRule *rul #define NM_SHUTDOWN_TIMEOUT_MAX_MSEC 1500 #define NM_SHUTDOWN_TIMEOUT_ADDITIONAL_MSEC 500 +/** + * NM_SHUTDOWN_TIMEOUT_1500_MSEC: this is just 1500 msec. The special + * thing about the define is that you are guaranteed that this is not + * longer than NM_SHUTDOWN_TIMEOUT_MAX_MSEC. + * When you perform an async operation, it must either be cancellable + * (and complete fast) or never take longer than NM_SHUTDOWN_TIMEOUT_MAX_MSEC. + * The usage of this macro makes that relation to NM_SHUTDOWN_TIMEOUT_MAX_MSEC + * explicit. + */ +#define NM_SHUTDOWN_TIMEOUT_1500_MSEC 1500 + typedef enum { /* There is no watched_obj argument, and the shutdown is delayed until the user * explicitly calls unregister on the returned handle. */ |