diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-11-24 01:42:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-24 01:42:48 +0100 |
commit | 00a60eaf5fcb3a0e415349aa649f2699550d26b0 (patch) | |
tree | 211135dfa606bf397a61c1a20db4a9d4b033f6d8 /src/resolve/resolved-manager.c | |
parent | core: add possibility to not track certain unit types (diff) | |
parent | io-util: document EINTR situation a bit (diff) | |
download | systemd-00a60eaf5fcb3a0e415349aa649f2699550d26b0.tar.xz systemd-00a60eaf5fcb3a0e415349aa649f2699550d26b0.zip |
Merge pull request #25483 from poettering/ppoll-usec-eintr
ppoll() + EINTR fixes
Diffstat (limited to 'src/resolve/resolved-manager.c')
-rw-r--r-- | src/resolve/resolved-manager.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c index f62efa87aa..1c9048670b 100644 --- a/src/resolve/resolved-manager.c +++ b/src/resolve/resolved-manager.c @@ -868,11 +868,14 @@ int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret) { } static int sendmsg_loop(int fd, struct msghdr *mh, int flags) { + usec_t end; int r; assert(fd >= 0); assert(mh); + end = usec_add(now(CLOCK_MONOTONIC), SEND_TIMEOUT_USEC); + for (;;) { if (sendmsg(fd, mh, flags) >= 0) return 0; @@ -881,20 +884,26 @@ static int sendmsg_loop(int fd, struct msghdr *mh, int flags) { if (errno != EAGAIN) return -errno; - r = fd_wait_for_event(fd, POLLOUT, SEND_TIMEOUT_USEC); - if (r < 0) + r = fd_wait_for_event(fd, POLLOUT, LESS_BY(end, now(CLOCK_MONOTONIC))); + if (r < 0) { + if (ERRNO_IS_TRANSIENT(r)) + continue; return r; + } if (r == 0) return -ETIMEDOUT; } } static int write_loop(int fd, void *message, size_t length) { + usec_t end; int r; assert(fd >= 0); assert(message); + end = usec_add(now(CLOCK_MONOTONIC), SEND_TIMEOUT_USEC); + for (;;) { if (write(fd, message, length) >= 0) return 0; @@ -903,9 +912,12 @@ static int write_loop(int fd, void *message, size_t length) { if (errno != EAGAIN) return -errno; - r = fd_wait_for_event(fd, POLLOUT, SEND_TIMEOUT_USEC); - if (r < 0) + r = fd_wait_for_event(fd, POLLOUT, LESS_BY(end, now(CLOCK_MONOTONIC))); + if (r < 0) { + if (ERRNO_IS_TRANSIENT(r)) + continue; return r; + } if (r == 0) return -ETIMEDOUT; } |