Changeset 3f95dab for benchmark/io/http/protocol.cfa
- Timestamp:
- Jul 28, 2022, 12:04:19 PM (21 months ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation
- Children:
- c4c8571
- Parents:
- 7ce8873
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/protocol.cfa
r7ce8873 r3f95dab 29 29 #define PLAINTEXT_MEMCPY 30 30 #define PLAINTEXT_NOCOPY 31 #define LINKED_IO31 // #define LINKED_IO 32 32 33 33 static inline __s32 wait_res( io_future_t & this ) { … … 72 72 if( ret < 0 ) { 73 73 if( errno == ECONNRESET || errno == EPIPE ) { close(fd); return -ECONNRESET; } 74 if( errno == EAGAIN || errno == EWOULDBLOCK) return -EAGAIN;75 74 76 75 abort( "'answer error' error: (%d) %s\n", (int)errno, strerror(errno) ); … … 152 151 } 153 152 154 static int sendfile( int pipe[2], int fd, int ans_fd, size_t count ) { 153 static int sendfile( int pipe[2], int fd, int ans_fd, size_t count, sendfile_stats_t & stats ) { 154 int zipf_idx = -1; 155 STATS: for(i; zipf_cnts) { 156 if(count <= zipf_sizes[i]) { 157 zipf_idx = i; 158 break STATS; 159 } 160 } 161 if(zipf_idx < 0) mutex(serr) serr | "SENDFILE" | count | " greated than biggest zipf file"; 162 163 155 164 unsigned sflags = SPLICE_F_MOVE; // | SPLICE_F_MORE; 156 165 off_t offset = 0; 157 166 ssize_t ret; 158 167 SPLICE1: while(count > 0) { 159 ret = cfa_splice(ans_fd, &offset, pipe[1], 0p, count, sflags, CFA_IO_LAZY); 160 if( ret < 0 ) { 161 if( errno != EAGAIN && errno != EWOULDBLOCK) continue SPLICE1; 168 stats.tries++; 169 // ret = cfa_splice(ans_fd, &offset, pipe[1], 0p, count, sflags, CFA_IO_LAZY); 170 ret = splice(ans_fd, &offset, pipe[1], 0p, count, sflags); 171 if( ret <= 0 ) { 162 172 if( errno == ECONNRESET ) return -ECONNRESET; 163 173 if( errno == EPIPE ) return -EPIPE; 164 abort( "splice [0] error: (%d) %s\n", (int)errno, strerror(errno) ); 165 } 166 174 abort( "splice [0] error: %d (%d) %s\n", ret, (int)errno, strerror(errno) ); 175 } 167 176 count -= ret; 177 stats.splcin++; 178 if(count > 0) stats.avgrd[zipf_idx].calls++; 179 stats.avgrd[zipf_idx].bytes += ret; 180 168 181 size_t in_pipe = ret; 169 182 SPLICE2: while(in_pipe > 0) { 170 ret = cfa_splice(pipe[0], 0p, fd, 0p, in_pipe, sflags, CFA_IO_LAZY);171 if( ret < 0 ) {172 if( errno != EAGAIN && errno != EWOULDBLOCK) continue SPLICE2;183 // ret = cfa_splice(pipe[0], 0p, fd, 0p, in_pipe, sflags, CFA_IO_LAZY); 184 ret = splice(pipe[0], 0p, fd, 0p, in_pipe, sflags); 185 if( ret <= 0 ) { 173 186 if( errno == ECONNRESET ) return -ECONNRESET; 174 187 if( errno == EPIPE ) return -EPIPE; 175 abort( "splice [1] error: (%d) %s\n", (int)errno, strerror(errno) );188 abort( "splice [1] error: %d (%d) %s\n", ret, (int)errno, strerror(errno) ); 176 189 } 190 stats.splcot++; 177 191 in_pipe -= ret; 178 192 } … … 506 520 return len + fsize; 507 521 #else 508 stats.tries++;509 522 int ret = answer_header(fd, fsize); 510 523 if( ret < 0 ) { close(fd); return ret; } 511 return sendfile(pipe, fd, ans_fd, fsize );524 return sendfile(pipe, fd, ans_fd, fsize, stats); 512 525 #endif 513 526 } … … 528 541 } 529 542 // int ret = read(fd, (void*)it, count); 530 if(ret == 0 ) return [OK200, true, 0, 0];543 if(ret == 0 ) { close(fd); return [OK200, true, 0, 0]; } 531 544 if(ret < 0 ) { 532 if( errno == EAGAIN || errno == EWOULDBLOCK) continue READ;533 545 if( errno == ECONNRESET ) { close(fd); return [E408, true, 0, 0]; } 534 546 if( errno == EPIPE ) { close(fd); return [E408, true, 0, 0]; }
Note: See TracChangeset
for help on using the changeset viewer.