函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:fs\splice.c Create Date:2022-07-29 10:42:09
首页 Copyright©Brick

538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
/**
 * splice_from_pipe_next - wait for some data to splice from
 * @pipe:   pipe to splice from
 * @sd:     information about the splice operation
 *
 * Description:
 *    This function will wait for some data and return a positive
 *    value (one) if pipe buffers are available.  It will return zero
 *    or -errno if no more data needs to be spliced.
 */
static int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
{
    /*
     * Check for signal early to make process killable when there are
     * always buffers available
     */
    if (signal_pending(current))
        return -ERESTARTSYS;
 
    while (pipe_empty(pipe->head, pipe->tail)) {
        if (!pipe->writers)
            return 0;
 
        if (sd->num_spliced)
            return 0;
 
        if (sd->flags & SPLICE_F_NONBLOCK)
            return -EAGAIN;
 
        if (signal_pending(current))
            return -ERESTARTSYS;
 
        if (sd->need_wakeup) {
            wakeup_pipe_writers(pipe);
            sd->need_wakeup = false;
        }
 
        pipe_wait(pipe);
    }
 
    return 1;
}