X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flibsystemd-rtnl%2Fsd-rtnl.c;h=b11a813dfe3cea502657b3b194dded9999eb563e;hb=98dd77e86e0cc339543cc8711ff908e6929f0636;hp=9938d463b05675136d01014ddaebaca5af7640c1;hpb=fe5c4e493e19f5b7979235783170c231dd7d008c;p=elogind.git diff --git a/src/libsystemd-rtnl/sd-rtnl.c b/src/libsystemd-rtnl/sd-rtnl.c index 9938d463b..b11a813df 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;