diff options
author | Tom Gundersen <teg@jklm.no> | 2013-10-29 16:35:37 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2013-10-29 16:37:30 +0100 |
commit | 98dd77e86e0cc339543cc8711ff908e6929f0636 (patch) | |
tree | bf17c71b1ec239b66cbe46f4f49466b326ca6b1f | |
parent | f1ac700248f231b7bdac2aafe8c35650efddb89f (diff) |
rtnl: introduce default timeout
We set it to 10 secs (as we are only communicating with the kernel,
it seems we should be able to bail out sooner than sd-bus, which
uses 25).
When passing timout 0, the default is used, use this in link-config.
-rw-r--r-- | src/libsystemd-rtnl/rtnl-internal.h | 3 | ||||
-rw-r--r-- | src/libsystemd-rtnl/sd-rtnl.c | 15 | ||||
-rw-r--r-- | src/udev/net/link-config.c | 2 |
3 files changed, 14 insertions, 6 deletions
diff --git a/src/libsystemd-rtnl/rtnl-internal.h b/src/libsystemd-rtnl/rtnl-internal.h index 37b1d3d021..f9c08e1a9a 100644 --- a/src/libsystemd-rtnl/rtnl-internal.h +++ b/src/libsystemd-rtnl/rtnl-internal.h @@ -33,6 +33,9 @@ struct sd_rtnl { unsigned serial; }; + +#define RTNL_DEFAULT_TIMEOUT ((usec_t) (10 * USEC_PER_SEC)) + int message_get_errno(sd_rtnl_message *m); int message_get_serial(sd_rtnl_message *m); int message_seal(sd_rtnl *nl, sd_rtnl_message *m); diff --git a/src/libsystemd-rtnl/sd-rtnl.c b/src/libsystemd-rtnl/sd-rtnl.c index 9938d463b0..b11a813dfe 100644 --- a/src/libsystemd-rtnl/sd-rtnl.c +++ b/src/libsystemd-rtnl/sd-rtnl.c @@ -109,10 +109,15 @@ int sd_rtnl_send_with_reply_and_block(sd_rtnl *nl, p[0].fd = nl->fd; p[0].events = POLLOUT; - timeout = now(CLOCK_MONOTONIC) + usec; + if (usec == (uint64_t) -1) + timeout = 0; + else if (usec == 0) + timeout = now(CLOCK_MONOTONIC) + RTNL_DEFAULT_TIMEOUT; + else + timeout = now(CLOCK_MONOTONIC) + usec; for (;;) { - if (usec != (uint64_t) -1) { + if (timeout) { usec_t n; n = now(CLOCK_MONOTONIC); @@ -122,7 +127,7 @@ int sd_rtnl_send_with_reply_and_block(sd_rtnl *nl, timespec_store(&left, timeout - n); } - r = ppoll(p, 1, usec == (uint64_t) -1 ? NULL : &left, NULL); + r = ppoll(p, 1, timeout ? &left : NULL, NULL); if (r < 0) return 0; @@ -140,7 +145,7 @@ int sd_rtnl_send_with_reply_and_block(sd_rtnl *nl, for (;;) { _cleanup_sd_rtnl_message_unref_ sd_rtnl_message *reply = NULL; - if (usec != (uint64_t) -1) { + if (timeout) { usec_t n; n = now(CLOCK_MONOTONIC); @@ -150,7 +155,7 @@ int sd_rtnl_send_with_reply_and_block(sd_rtnl *nl, timespec_store(&left, timeout - n); } - r = ppoll(p, 1, usec == (uint64_t) -1 ? NULL : &left, NULL); + r = ppoll(p, 1, timeout ? &left : NULL, NULL); if (r < 0) return r; diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index a86c74d5f7..9d6c96b5a5 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -293,7 +293,7 @@ static int rtnl_set_properties(sd_rtnl *rtnl, int ifindex, const char *name, con } if (need_update) { - r = sd_rtnl_send_with_reply_and_block(rtnl, message, 5 * USEC_PER_SEC, NULL); + r = sd_rtnl_send_with_reply_and_block(rtnl, message, 0, NULL); if (r < 0) return r; } |