diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2013-04-05 07:12:25 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2013-04-05 07:12:25 +0000 |
commit | e9854ae35b453274b26baf0f7889096dfab0c94c (patch) | |
tree | 1cef5f005d9ee56640fb041a0ff21942f14a70e8 | |
parent | 8536394f88af20a86c689300a885160d1a682150 (diff) |
do not fail on EINTR
suggested by deraadt@
-rw-r--r-- | lib/libc/asr/res_send_async.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/libc/asr/res_send_async.c b/lib/libc/asr/res_send_async.c index e8457c26bc5..487890fa318 100644 --- a/lib/libc/asr/res_send_async.c +++ b/lib/libc/asr/res_send_async.c @@ -1,4 +1,4 @@ -/* $OpenBSD: res_send_async.c,v 1.14 2013/04/03 19:38:20 matthew Exp $ */ +/* $OpenBSD: res_send_async.c,v 1.15 2013/04/05 07:12:24 eric Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -557,9 +557,13 @@ tcp_write(struct async *as) msg.msg_iov = iov; msg.msg_iovlen = i; + send_again: n = sendmsg(as->as_fd, &msg, MSG_NOSIGNAL); - if (n == -1) + if (n == -1) { + if (errno == EINTR) + goto send_again; goto close; /* errno set */ + } as->as.dns.datalen += n; @@ -613,9 +617,13 @@ tcp_read(struct async *as) pfd.fd = as->as_fd; pfd.events = POLLIN; + poll_again: nfds = poll(&pfd, 1, 0); - if (nfds == -1) + if (nfds == -1) { + if (errno == EINTR) + goto poll_again; goto close; /* errno set */ + } if (nfds == 0) return (1); /* no more data available */ } @@ -624,9 +632,13 @@ tcp_read(struct async *as) pos = as->as.dns.ibuf + offset; len = as->as.dns.ibuflen - offset; + read_again: n = read(as->as_fd, pos, len); - if (n == -1) + if (n == -1) { + if (errno == EINTR) + goto read_again; goto close; /* errno set */ + } if (n == 0) { errno = ECONNRESET; goto close; |