From 0f6bf3575e587354fcd0dd274fa0d27210cc9ac6 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 31 Dec 2014 14:27:03 +0100 Subject: [PATCH] smbd: Properly handle EINTR in vfs_aio_fork Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- source3/modules/vfs_aio_fork.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source3/modules/vfs_aio_fork.c b/source3/modules/vfs_aio_fork.c index 7d2aff90644..bf29dd1e018 100644 --- a/source3/modules/vfs_aio_fork.c +++ b/source3/modules/vfs_aio_fork.c @@ -170,8 +170,12 @@ static ssize_t read_fd(int fd, void *ptr, size_t nbytes, int *recvfd) msg.msg_iov = iov; msg.msg_iovlen = 1; - if ( (n = recvmsg(fd, &msg, 0)) <= 0) { - return(n); + do { + n = recvmsg(fd, &msg, 0); + } while ((n == -1) && (errno == EINTR)); + + if (n <= 0) { + return n; } { @@ -203,6 +207,7 @@ static ssize_t write_fd(int fd, void *ptr, size_t nbytes, int sendfd) size_t bufsize = msghdr_prep_fds(NULL, NULL, 0, &sendfd, 1); uint8_t buf[bufsize]; struct iovec iov; + ssize_t sent; msghdr_prep_fds(&msg, buf, bufsize, &sendfd, 1); msg.msg_name = NULL; @@ -213,7 +218,11 @@ static ssize_t write_fd(int fd, void *ptr, size_t nbytes, int sendfd) msg.msg_iov = &iov; msg.msg_iovlen = 1; - return (sendmsg(fd, &msg, 0)); + do { + sent = sendmsg(fd, &msg, 0); + } while ((sent == -1) && (errno == EINTR)); + + return sent; } static void aio_child_cleanup(struct tevent_context *event_ctx, -- 2.11.4.GIT