Ignore:
Timestamp:
Jul 16, 2020, 3:22:01 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
5db836e
Parents:
463cb33
Message:

Moved sendfile to protocol.cfa to reduce compilation time

File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/io/http/protocol.cfa

    r463cb33 rc82af9f  
    11#include "protocol.hfa"
    22
     3#define _GNU_SOURCE
     4extern "C" {
     5        #include <fcntl.h>
     6}
    37#include <iofwd.hfa>
    48
     
    8387        return [OK200, false, it, end - it];
    8488}
     89
     90void sendfile( int pipe[2], int fd, int ans_fd, size_t count ) {
     91        off_t offset = 0;
     92        ssize_t ret;
     93        SPLICE1: while(count > 0) {
     94                ret = cfa_splice(ans_fd, &offset, pipe[1], 0p, count, SPLICE_F_MOVE | SPLICE_F_MORE);
     95                if( ret < 0 ) {
     96                        if( errno != EAGAIN && errno != EWOULDBLOCK) continue SPLICE1;
     97                        abort( "splice [0] error: (%d) %s\n", (int)errno, strerror(errno) );
     98                }
     99
     100                count -= ret;
     101                offset += ret;
     102                size_t in_pipe = ret;
     103                SPLICE2: while(in_pipe > 0) {
     104                        ret = cfa_splice(pipe[0], 0p, fd, 0p, in_pipe, SPLICE_F_MOVE | SPLICE_F_MORE);
     105                        if( ret < 0 ) {
     106                                if( errno != EAGAIN && errno != EWOULDBLOCK) continue SPLICE2;
     107                                abort( "splice [1] error: (%d) %s\n", (int)errno, strerror(errno) );
     108                        }
     109                        in_pipe -= ret;
     110                }
     111
     112        }
     113}
Note: See TracChangeset for help on using the changeset viewer.