Changeset ee59ede
- Timestamp:
- Jan 14, 2021, 2:32:18 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 153dc387
- Parents:
- 7222630
- Location:
- benchmark/io/http
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/protocol.cfa
r7222630 ree59ede 24 24 "HTTP/1.1 400 Bad Request\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 0 \n\n", 25 25 "HTTP/1.1 404 Not Found\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 0 \n\n", 26 "HTTP/1.1 408 Request Timeout\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 0 \n\n", 26 27 "HTTP/1.1 413 Payload Too Large\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 0 \n\n", 27 28 "HTTP/1.1 414 URI Too Long\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 0 \n\n", … … 34 35 400, 35 36 404, 37 408, 36 38 413, 37 39 414, … … 49 51 int ret = cfa_write(fd, it, len, 0, -1`s, 0p, 0p); 50 52 // int ret = write(fd, it, len); 51 if( ret < 0 ) { if( errno != EAGAIN && errno != EWOULDBLOCK) abort( "'answer error' error: (%d) %s\n", (int)errno, strerror(errno) ); } 53 if( ret < 0 ) { 54 if( errno == ECONNRESET || errno == EPIPE ) return -ECONNRESET; 55 if( errno == EAGAIN || errno == EWOULDBLOCK) return -EAGAIN; 56 57 abort( "'answer error' error: (%d) %s\n", (int)errno, strerror(errno) ); 58 } 52 59 53 60 // update it/len … … 94 101 if(ret < 0 ) { 95 102 if( errno == EAGAIN || errno == EWOULDBLOCK) continue READ; 96 // if( errno == EINVAL ) return [E400, true, 0, 0];103 if( errno == ECONNRESET ) return [E408, true, 0, 0]; 97 104 abort( "read error: (%d) %s\n", (int)errno, strerror(errno) ); 98 105 } … … 119 126 } 120 127 121 voidsendfile( int pipe[2], int fd, int ans_fd, size_t count ) {128 int sendfile( int pipe[2], int fd, int ans_fd, size_t count ) { 122 129 unsigned sflags = SPLICE_F_MOVE; // | SPLICE_F_MORE; 123 130 off_t offset = 0; … … 128 135 if( ret < 0 ) { 129 136 if( errno != EAGAIN && errno != EWOULDBLOCK) continue SPLICE1; 137 if( errno == ECONNRESET ) return -ECONNRESET; 138 if( errno == EPIPE ) return -EPIPE; 130 139 abort( "splice [0] error: (%d) %s\n", (int)errno, strerror(errno) ); 131 140 } … … 139 148 if( ret < 0 ) { 140 149 if( errno != EAGAIN && errno != EWOULDBLOCK) continue SPLICE2; 150 if( errno == ECONNRESET ) return -ECONNRESET; 151 if( errno == EPIPE ) return -EPIPE; 141 152 abort( "splice [1] error: (%d) %s\n", (int)errno, strerror(errno) ); 142 153 } … … 145 156 146 157 } 158 return count; 147 159 } 148 160 -
benchmark/io/http/protocol.hfa
r7222630 ree59ede 7 7 E400, 8 8 E404, 9 E408, 9 10 E413, 10 11 E414, … … 21 22 [HttpCode code, bool closed, * const char file, size_t len] http_read(int fd, []char buffer, size_t len, io_cancellation *); 22 23 23 voidsendfile( int pipe[2], int fd, int ans_fd, size_t count );24 int sendfile( int pipe[2], int fd, int ans_fd, size_t count ); -
benchmark/io/http/worker.cfa
r7222630 ree59ede 38 38 if(fd < 0) { 39 39 if( errno == ECONNABORTED ) break; 40 if( errno == EINVAL && this.done) break;40 if( this.done && (errno == EINVAL || errno == EBADF) ) break; 41 41 abort( "accept error: (%d) %s\n", (int)errno, strerror(errno) ); 42 42 } … … 57 57 58 58 // if we are done, break out of the loop 59 if( closed ) { 60 if( options.log ) printf("=== Connection closed ===\n"); 61 close(fd); 62 continue CONNECTION; 63 } 59 if( closed ) break REQUEST; 64 60 65 61 // If this wasn't a request retrun 400 … … 76 72 77 73 // Send the header 78 answer_plain(fd, text, sizeof(text)); 74 int ret = answer_plain(fd, text, sizeof(text)); 75 if( ret == -ECONNRESET ) break REQUEST; 79 76 80 77 if( options.log ) printf("=== Answer sent ===\n"); … … 86 83 87 84 // Send the header 88 answer_empty(fd); 85 int ret = answer_empty(fd); 86 if( ret == -ECONNRESET ) break REQUEST; 89 87 90 88 if( options.log ) printf("=== Answer sent ===\n"); … … 107 105 108 106 // Send the header 109 answer_header(fd, count); 107 int ret = answer_header(fd, count); 108 if( ret == -ECONNRESET ) break REQUEST; 110 109 111 110 // Send the desired file 112 sendfile( this.pipe, fd, ans_fd, count); 111 ret = sendfile( this.pipe, fd, ans_fd, count); 112 if( ret == -ECONNRESET ) break REQUEST; 113 113 114 114 if( options.log ) printf("=== Answer sent ===\n"); 115 115 } 116 117 if( options.log ) printf("=== Connection closed ===\n"); 118 close(fd); 119 continue CONNECTION; 116 120 } 117 121 }
Note: See TracChangeset
for help on using the changeset viewer.