From 9c3653b1e1bf4a8f74213fb9aa87ccf30bc87cb1 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sat, 22 Jan 2022 23:59:37 +0300 Subject: [PATCH] Handle EINTR --- src/http_client.cpp | 4 ++-- src/msgr_receive.cpp | 4 ++-- src/msgr_send.cpp | 2 +- src/rw_blocking.cpp | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/http_client.cpp b/src/http_client.cpp index 8f6eba90..4c348031 100644 --- a/src/http_client.cpp +++ b/src/http_client.cpp @@ -381,7 +381,7 @@ again: { res = -errno; } - if (res == -EAGAIN) + if (res == -EAGAIN || res == -EINTR) { res = 0; } @@ -431,7 +431,7 @@ void http_co_t::submit_read() { res = -errno; } - if (res == -EAGAIN) + if (res == -EAGAIN || res == -EINTR) { epoll_events = epoll_events & ~EPOLLIN; } diff --git a/src/msgr_receive.cpp b/src/msgr_receive.cpp index 0f2e90f7..b150f3c3 100644 --- a/src/msgr_receive.cpp +++ b/src/msgr_receive.cpp @@ -67,7 +67,7 @@ bool osd_messenger_t::handle_read(int result, osd_client_t *cl) } return false; } - if (result <= 0 && result != -EAGAIN) + if (result <= 0 && result != -EAGAIN && result != -EINTR) { // this is a client socket, so don't panic on error. just disconnect it if (result != 0) @@ -77,7 +77,7 @@ bool osd_messenger_t::handle_read(int result, osd_client_t *cl) stop_client(cl->peer_fd); return false; } - if (result == -EAGAIN || result < cl->read_iov.iov_len) + if (result == -EAGAIN || result == -EINTR || result < cl->read_iov.iov_len) { cl->read_ready--; if (cl->read_ready > 0) diff --git a/src/msgr_send.cpp b/src/msgr_send.cpp index a8f73427..5248e641 100644 --- a/src/msgr_send.cpp +++ b/src/msgr_send.cpp @@ -224,7 +224,7 @@ void osd_messenger_t::handle_send(int result, osd_client_t *cl) } return; } - if (result < 0 && result != -EAGAIN) + if (result < 0 && result != -EAGAIN && result != -EINTR) { // this is a client socket, so don't panic. just disconnect it fprintf(stderr, "Client %d socket write error: %d (%s). Disconnecting client\n", cl->peer_fd, -result, strerror(-result)); diff --git a/src/rw_blocking.cpp b/src/rw_blocking.cpp index e644ae12..ae2faeb0 100644 --- a/src/rw_blocking.cpp +++ b/src/rw_blocking.cpp @@ -23,7 +23,7 @@ int read_blocking(int fd, void *read_buf, size_t remaining) // EOF return done; } - else if (errno != EAGAIN && errno != EPIPE) + else if (errno != EINTR && errno != EAGAIN && errno != EPIPE) { perror("read"); exit(1); @@ -44,7 +44,7 @@ int write_blocking(int fd, void *write_buf, size_t remaining) size_t r = write(fd, write_buf, remaining-done); if (r < 0) { - if (errno != EAGAIN && errno != EPIPE) + if (errno != EINTR && errno != EAGAIN && errno != EPIPE) { perror("write"); exit(1); @@ -66,7 +66,7 @@ int readv_blocking(int fd, iovec *iov, int iovcnt) ssize_t r = readv(fd, iov+v, iovcnt-v); if (r < 0) { - if (errno != EAGAIN && errno != EPIPE) + if (errno != EINTR && errno != EAGAIN && errno != EPIPE) { perror("writev"); exit(1); @@ -101,7 +101,7 @@ int writev_blocking(int fd, iovec *iov, int iovcnt) ssize_t r = writev(fd, iov+v, iovcnt-v); if (r < 0) { - if (errno != EAGAIN && errno != EPIPE) + if (errno != EINTR && errno != EAGAIN && errno != EPIPE) { perror("writev"); exit(1); @@ -139,7 +139,7 @@ int sendv_blocking(int fd, iovec *iov, int iovcnt, int flags) ssize_t r = sendmsg(fd, &msg, flags); if (r < 0) { - if (errno != EAGAIN && errno != EPIPE) + if (errno != EINTR && errno != EAGAIN && errno != EPIPE) { perror("sendmsg"); exit(1);