sendfile(2) SF_NOPUSH flag proposal

Igor Sysoev is at rambler-co.ru
Wed May 28 12:56:27 PDT 2003


On Wed, 28 May 2003, Bill Fenner wrote:

> Why not set PRUS_MORETOCOME on all but the final pru_send() call?

I think it's a good solution.  We can

1) use TF_NOPUSH to coalesce the header and the first file part 
   or the last file part and the trailer as Matthew Dillon suggested;

2) use the same TF_NOPUSH to postpone the sending partial packet while
   a reading file page from the disk;

3) and use PRUS_MORETOCOME to avoid partial packet after EAGAIN
   on non-blocking socket.

---------- 
sendfile()
{
    saved = tp->t_flags & TF_NOPUSH;
    if (header) {
        writev(header);
    }

    if (file) {
        send file pages with PRUS_MORETOCOME
    }

    if (trailer) {
        writev(trailer);
    }

done:
    if (sendfile completed) {
        tp->t_flags &= ~TF_MORETOCOME;
    }

    tp->t_flags |= saved;
    if (saved & TF_NOPUSH) {
        tcp_output(tp);
    }
}
----------

As I understand TF_MORETOCOME should postpone the sending the partially
filled packet after sendfile will return EAGAIN.


Igor Sysoev
http://sysoev.ru/en/



More information about the freebsd-arch mailing list