Changes in benchmark/io/http/worker.cfa [32d1383:3f95dab]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/worker.cfa
r32d1383 r3f95dab 14 14 #include "filecache.hfa" 15 15 16 static const unsigned long long period = 5 _000_000;16 static const unsigned long long period = 50_000_000; 17 17 18 18 //============================================================================================= … … 33 33 34 34 // if we are done, break out of the loop 35 if( closed ) { 36 if( code != OK200 ) this.stats.sendfile.error++; 37 break REQUEST; 38 } 35 if( closed ) break REQUEST; 39 36 40 37 // If this wasn't a request retrun 400 41 38 if( code != OK200 ) { 42 abort | "=== Invalid Request :" | code_val(code) | "===";43 //answer_error(fd, code);44 //continue REQUEST;45 } 46 47 //if(0 == strncmp(file, "plaintext", min(name_size, sizeof("plaintext") ))) {48 //if( options.log ) mutex(sout) sout | "=== Request for /plaintext ===";49 50 //int ret = answer_plaintext(fd);51 // if( ret == -ECONNRESET ) { this.stats.sendfile.error++; break REQUEST; }52 53 //if( options.log ) mutex(sout) sout | "=== Answer sent ===";54 //continue REQUEST;55 //}56 57 //if(0 == strncmp(file, "ping", min(name_size, sizeof("ping") ))) {58 //if( options.log ) mutex(sout) sout | "=== Request for /ping ===";59 60 //// Send the header61 //int ret = answer_empty(fd);62 // if( ret == -ECONNRESET ) { this.stats.sendfile.error++; break REQUEST; }63 64 //if( options.log ) mutex(sout) sout | "=== Answer sent ===";65 //continue REQUEST;66 //}39 sout | "=== Invalid Request :" | code_val(code) | "==="; 40 answer_error(fd, code); 41 continue REQUEST; 42 } 43 44 if(0 == strncmp(file, "plaintext", min(name_size, sizeof("plaintext") ))) { 45 if( options.log ) mutex(sout) sout | "=== Request for /plaintext ==="; 46 47 int ret = answer_plaintext(fd); 48 if( ret == -ECONNRESET ) break REQUEST; 49 50 if( options.log ) mutex(sout) sout | "=== Answer sent ==="; 51 continue REQUEST; 52 } 53 54 if(0 == strncmp(file, "ping", min(name_size, sizeof("ping") ))) { 55 if( options.log ) mutex(sout) sout | "=== Request for /ping ==="; 56 57 // Send the header 58 int ret = answer_empty(fd); 59 if( ret == -ECONNRESET ) break REQUEST; 60 61 if( options.log ) mutex(sout) sout | "=== Answer sent ==="; 62 continue REQUEST; 63 } 67 64 68 65 if( options.log ) { … … 73 70 74 71 if( !options.file_cache.path ) { 75 // if( options.log ) { 76 serr | "=== File Not Found (" | nonl; 77 write(serr, file, name_size); 78 serr | ") ==="; 79 abort(); 80 // } 81 // answer_error(fd, E405); 82 // continue REQUEST; 72 if( options.log ) { 73 sout | "=== File Not Found (" | nonl; 74 write(sout, file, name_size); 75 sout | ") ==="; 76 } 77 answer_error(fd, E405); 78 continue REQUEST; 83 79 } 84 80 … … 90 86 // If we can't find the file, return 404 91 87 if( ans_fd < 0 ) { 92 // if( options.log ) { 93 serr | "=== File Not Found 2 (" | nonl; 94 write(serr, file, name_size); 95 serr | ") ==="; 96 abort(); 97 // } 98 // answer_error(fd, E404); 99 // continue REQUEST; 88 if( options.log ) { 89 sout | "=== File Not Found (" | nonl; 90 write(sout, file, name_size); 91 sout | ") ==="; 92 } 93 answer_error(fd, E404); 94 continue REQUEST; 100 95 } 101 96 … … 103 98 int ret = answer_sendfile( this.pipe, fd, ans_fd, count, this.stats.sendfile ); 104 99 if(ret < 0) { 105 if( ret == -ECONNABORTED ) { this.stats.sendfile.error++; break REQUEST; } 106 if( ret == -ECONNRESET ) { this.stats.sendfile.error++; break REQUEST; } 107 if( ret == -EPIPE ) { this.stats.sendfile.error++; break REQUEST; } 108 if( ret == -EBADF ) { this.stats.sendfile.error++; break REQUEST; } 109 abort( "answer sendfile error: %d (%d) %s\n", ret, (int)errno, strerror(errno) ); 100 if( ret == -ECONNABORTED ) break REQUEST; 101 if( ret == -ECONNRESET ) break REQUEST; 102 if( ret == -EPIPE ) break REQUEST; 103 abort( "sendfile error: %d (%d) %s\n", ret, (int)errno, strerror(errno) ); 110 104 } 111 105 … … 113 107 } 114 108 115 this.stats.sendfile.close++;116 117 109 if (stats_thrd) { 118 //unsigned long long next = rdtscl();119 //if(next > (last + period)) {110 unsigned long long next = rdtscl(); 111 if(next > (last + period)) { 120 112 if(try_lock(stats_thrd->stats.lock __cfaabi_dbg_ctx2)) { 121 113 push(this.stats.sendfile, stats_thrd->stats.send); 122 114 unlock(stats_thrd->stats.lock); 123 //last = next;124 } 125 //}115 last = next; 116 } 117 } 126 118 } 127 119 } … … 152 144 if(this.done) break; 153 145 154 this.stats.accepts++;155 if (stats_thrd && try_lock(stats_thrd->stats.lock)) {156 push(this.stats, stats_thrd->stats.accpt);157 unlock(stats_thrd->stats.lock);158 }159 160 146 if( options.log ) mutex(sout) sout | "=== New connection" | fd | "" | ", waiting for requests ==="; 161 147 size_t len = options.socket.buflen; … … 163 149 handle_connection( this.conn, fd, buffer, len, 0p, last ); 164 150 this.conn.stats.sendfile.maxfd = max(this.conn.stats.sendfile.maxfd, fd); 151 this.conn.stats.sendfile.close++; 165 152 166 153 if( options.log ) mutex(sout) sout | "=== Connection closed ==="; … … 185 172 /* paranoid */ assert( this.conn.pipe[1] != -1 ); 186 173 this.conn.stats.sendfile.maxfd = max(this.conn.pipe[0], this.conn.pipe[1]); 187 // this.conn.stats.sendfile.maxfd = 0;188 174 for() { 189 175 size_t len = options.socket.buflen; … … 234 220 p = pop(*this.queue); 235 221 if(p) break; 236 // abort( "Too few threads" );237 222 yield(); 238 223 this.stats.creates++; … … 303 288 304 289 if (stats_thrd) { 305 //unsigned long long next = rdtscl();306 //if(next > (last + period)) {290 unsigned long long next = rdtscl(); 291 if(next > (last + period)) { 307 292 if(try_lock(stats_thrd->stats.lock)) { 308 293 push(this.stats, stats_thrd->stats.accpt); 309 294 unlock(stats_thrd->stats.lock); 310 //last = next;295 last = next; 311 296 } 312 //}297 } 313 298 } 314 299
Note: See TracChangeset
for help on using the changeset viewer.