]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: make safe_splice return if return value is EAGAIN. 4329/head
authorJianpeng Ma <jianpeng.ma@intel.com>
Thu, 11 Jun 2015 08:54:08 +0000 (16:54 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Thu, 11 Jun 2015 08:54:08 +0000 (16:54 +0800)
If splice data from normal file into pipe and pipe has no enough
buffer(see fcntl), splice will block. If splice flags w/
SPLICE_F_NONBLOCK, in this situation splice will return EAGAIN.
In this situation, we should return and let the caller handle this(read
splice).
This happen the splice read/write in the same thread and first
splice read from normal file and later splice write to normal file.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/common/safe_io.c

index 76fd25aca1229951068a5c1989c5f55d1b21d7f1..9367a9abb969fbdce0514cc30ec69be45a5cf357 100644 (file)
@@ -133,6 +133,8 @@ ssize_t safe_splice(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out,
       }
       if (errno == EINTR)
        continue;
+      if (errno == EAGAIN)
+       break;
       return -errno;
     }
     cnt += r;