mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 02:00:14 +01:00
platform/tests: extend nmtstp_wait_for_link*() to never wait
Previously, it was not (reliably) possible to use nmtstp_wait_for_link*() to only look into the platform cache, without trying to poll the netlink socket for events. Add this option. Now, if the timeout is specified as zero, we never actually read the netlink socket. Currently, there are no callers who make use of this (by passing a zero timeout). So, this is no change in existing behavior.
This commit is contained in:
parent
dd2f5cf3d4
commit
f21ff48a84
1 changed files with 17 additions and 2 deletions
|
|
@ -628,7 +628,10 @@ nmtstp_wait_for_signal_until (NMPlatform *platform, gint64 until_ms)
|
|||
const NMPlatformLink *
|
||||
nmtstp_wait_for_link (NMPlatform *platform, const char *ifname, NMLinkType expected_link_type, gint64 timeout_ms)
|
||||
{
|
||||
return nmtstp_wait_for_link_until (platform, ifname, expected_link_type, nm_utils_get_monotonic_timestamp_ms () + timeout_ms);
|
||||
return nmtstp_wait_for_link_until (platform, ifname, expected_link_type,
|
||||
timeout_ms
|
||||
? nm_utils_get_monotonic_timestamp_ms () + timeout_ms
|
||||
: 0);
|
||||
}
|
||||
|
||||
const NMPlatformLink *
|
||||
|
|
@ -636,6 +639,7 @@ nmtstp_wait_for_link_until (NMPlatform *platform, const char *ifname, NMLinkType
|
|||
{
|
||||
const NMPlatformLink *plink;
|
||||
gint64 now;
|
||||
gboolean waited_once = FALSE;
|
||||
|
||||
_init_platform (&platform, FALSE);
|
||||
|
||||
|
|
@ -647,9 +651,20 @@ nmtstp_wait_for_link_until (NMPlatform *platform, const char *ifname, NMLinkType
|
|||
&& (expected_link_type == NM_LINK_TYPE_NONE || plink->type == expected_link_type))
|
||||
return plink;
|
||||
|
||||
if (until_ms < now)
|
||||
if (until_ms == 0) {
|
||||
/* don't wait, don't even poll the socket. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( waited_once
|
||||
&& until_ms < now) {
|
||||
/* timeout reached (+ we already waited for a signal at least once). */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
waited_once = TRUE;
|
||||
/* regardless of whether timeout is already reached, we poll the netlink
|
||||
* socket a bit. */
|
||||
nmtstp_wait_for_signal (platform, until_ms - now);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue