- Timestamp:
- Jun 10, 2022, 4:12:40 PM (3 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- bf7c7ea
- Parents:
- 10ba012
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/worker.cfa
r10ba012 rc25338d 187 187 } 188 188 189 #define ACCEPT_SPIN 190 189 191 void main( Acceptor & this ) { 190 192 park(); 191 193 unsigned long long last = rdtscl(); 194 195 #if defined(ACCEPT_SPIN) 192 196 if( options.log ) sout | "=== Accepting connection ==="; 193 197 for() { … … 236 240 if( options.log ) sout | "=== Accepting connection ==="; 237 241 } 238 } 242 243 #elif define(ACCEPT_MANY) 244 const int nacc = 10; 245 io_future_t results[nacc]; 246 247 for(i; nacc) { 248 io_future_t & res = results[i]; 249 reset(res); 250 /* paranoid */ assert(!available(res)); 251 if( options.log ) mutex(sout) sout | "=== Re-arming accept no" | i | " ==="; 252 async_accept4(res, this.sockfd, this.[addr, addrlen, flags], CFA_IO_LAZY); 253 } 254 255 for() { 256 if (stats_thrd) { 257 unsigned long long next = rdtscl(); 258 if(next > (last + 500000000)) { 259 if(try_lock(stats_thrd->stats.lock __cfaabi_dbg_ctx2)) { 260 push(this.stats, stats_thrd->stats.accpt); 261 unlock(stats_thrd->stats.lock); 262 last = next; 263 } 264 } 265 } 266 267 for(i; nacc) { 268 io_future_t & res = results[i]; 269 if(available(res)) { 270 if( options.log ) mutex(sout) sout | "=== Accept no " | i | "completed with result" | res.result | "==="; 271 int fd = get_res(res); 272 reset(res); 273 this.stats.accepts++; 274 if(fd < 0) { 275 if( errno == ECONNABORTED ) continue; 276 if( this.done && (errno == EINVAL || errno == EBADF) ) continue; 277 abort( "accept error: (%d) %s\n", (int)errno, strerror(errno) ); 278 } 279 push_connection( this, fd ); 280 281 /* paranoid */ assert(!available(res)); 282 if( options.log ) mutex(sout) sout | "=== Re-arming accept no" | i | " ==="; 283 async_accept4(res, this.sockfd, this.[addr, addrlen, flags], CFA_IO_LAZY); 284 } 285 } 286 if(this.done) return; 287 288 if( options.log ) mutex(sout) sout | "=== Waiting for any accept ==="; 289 this.stats.eagains++; 290 wait_any(results, nacc); 291 292 if( options.log ) mutex(sout) { 293 sout | "=== Acceptor wake-up ==="; 294 for(i; nacc) { 295 io_future_t & res = results[i]; 296 sout | i | "available:" | available(res); 297 } 298 } 299 300 } 301 302 for(i; nacc) { 303 wait(results[i]); 304 } 305 #else 306 #error no accept algorithm specified 307 #endif 308 }
Note: See TracChangeset
for help on using the changeset viewer.