smbd: Properly handle EINTR in vfs_aio_fork
authorVolker Lendecke <vl@samba.org>
Wed, 31 Dec 2014 13:27:03 +0000 (14:27 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 5 Jan 2015 23:33:10 +0000 (00:33 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_aio_fork.c

index 7d2aff9064462a29d3559a3351523f3771617145..bf29dd1e0182dabd8f1580e741d079a9e6da3a98 100644 (file)
@@ -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,