Ignore:
Timestamp:
Jul 16, 2020, 3:22:01 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, 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/worker.cfa

    r463cb33 rc82af9f  
    11#include "worker.hfa"
    2 
    3 #define __USE_GNU
    42
    53#include <errno.h>
    64#include <stdio.h>
    75#include <string.h>
    8 extern "C" {
    9         #include <fcntl.h>
    10         #include <sys/socket.h>
    11         #include <sys/types.h>
    12         #include <netinet/in.h>
    13 }
     6#include <unistd.h>
    147
    158#include <iofwd.hfa>
     
    3225// Worker Thread
    3326//=============================================================================================
    34 void sendfile( Worker & this, int fd, int ans_fd, size_t count ) {
    35         off_t offset = 0;
    36         ssize_t ret;
    37         SPLICE1: while(count > 0) {
    38                 ret = cfa_splice(ans_fd, &offset, this.pipe[1], 0p, count, SPLICE_F_MOVE | SPLICE_F_MORE);
    39                 if( ret < 0 ) {
    40                         if( errno != EAGAIN && errno != EWOULDBLOCK) continue SPLICE1;
    41                         abort( "splice [0] error: (%d) %s\n", (int)errno, strerror(errno) );
    42                 }
    43 
    44                 count -= ret;
    45                 offset += ret;
    46                 size_t in_pipe = ret;
    47                 SPLICE2: while(in_pipe > 0) {
    48                         ret = cfa_splice(this.pipe[0], 0p, fd, 0p, in_pipe, SPLICE_F_MOVE | SPLICE_F_MORE);
    49                         if( ret < 0 ) {
    50                                 if( errno != EAGAIN && errno != EWOULDBLOCK) continue SPLICE2;
    51                                 abort( "splice [1] error: (%d) %s\n", (int)errno, strerror(errno) );
    52                         }
    53                         in_pipe -= ret;
    54                 }
    55 
    56         }
    57 }
    58 
    5927void ?{}( Worker & this ) {
    6028        ((thread&)this){ "Server Worker Thread", *options.the_cluster };
     
    11179
    11280                        // Send the desired file
    113                         sendfile( this, fd, ans_fd, count);
     81                        sendfile( this.pipe, fd, ans_fd, count);
    11482
    11583                        printf("File sent\n");
Note: See TracChangeset for help on using the changeset viewer.