Changeset c82af9f
- Timestamp:
- Jul 16, 2020, 3:22:01 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 5db836e
- Parents:
- 463cb33
- Location:
- benchmark/io/http
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/protocol.cfa
r463cb33 rc82af9f 1 1 #include "protocol.hfa" 2 2 3 #define _GNU_SOURCE 4 extern "C" { 5 #include <fcntl.h> 6 } 3 7 #include <iofwd.hfa> 4 8 … … 83 87 return [OK200, false, it, end - it]; 84 88 } 89 90 void 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 } -
benchmark/io/http/protocol.hfa
r463cb33 rc82af9f 14 14 15 15 [HttpCode code, bool closed, * const char file, size_t len] http_read(int fd, []char buffer, size_t len); 16 17 void sendfile( int pipe[2], int fd, int ans_fd, size_t count ); -
benchmark/io/http/worker.cfa
r463cb33 rc82af9f 1 1 #include "worker.hfa" 2 3 #define __USE_GNU4 2 5 3 #include <errno.h> 6 4 #include <stdio.h> 7 5 #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> 14 7 15 8 #include <iofwd.hfa> … … 32 25 // Worker Thread 33 26 //============================================================================================= 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 59 27 void ?{}( Worker & this ) { 60 28 ((thread&)this){ "Server Worker Thread", *options.the_cluster }; … … 111 79 112 80 // Send the desired file 113 sendfile( this , fd, ans_fd, count);81 sendfile( this.pipe, fd, ans_fd, count); 114 82 115 83 printf("File sent\n");
Note: See TracChangeset
for help on using the changeset viewer.