Changeset b664af2
- Timestamp:
- Feb 24, 2021, 12:26:45 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:
- 2caed18
- Parents:
- 348f81d5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/http_ring.cpp
r348f81d5 rb664af2 68 68 thread_local stats_block_t stats; 69 69 stats_block_t global_stats; 70 71 thread_local struct __attribute__((aligned(128))) { 72 size_t to_submit = 0; 73 } local; 70 74 71 75 // Get an array of current connections … … 193 197 static void submit(struct io_uring * ring, struct io_uring_sqe * sqe, connection * conn) { 194 198 (void)ring; 199 local.to_submit++; 195 200 #ifdef USE_ASYNC 196 201 io_uring_sqe_set_flags(sqe, IOSQE_ASYNC); … … 407 412 switch(state) { 408 413 case ACCEPTING: 409 connection::accept(ring, opt);414 // connection::accept(ring, opt); 410 415 newconn(ring, res); 411 416 break; … … 421 426 422 427 //========================================================= 428 extern "C" { 429 #include <sys/eventfd.h> // use for termination 430 } 431 423 432 // Main loop of the WebServer 424 433 // Effectively uses one thread_local copy of everything per kernel thread … … 427 436 struct options_t & opt = *(struct options_t *)arg; 428 437 struct io_uring * ring = opt.ring; 438 439 int blockfd = eventfd(0, 0); 440 if (blockfd < 0) { 441 fprintf( stderr, "eventfd create error: (%d) %s\n", (int)errno, strerror(errno) ); 442 exit(EXIT_FAILURE); 443 } 444 445 int ret = io_uring_register_eventfd(ring, blockfd); 446 if (ret < 0) { 447 fprintf( stderr, "io_uring S&W error: (%d) %s\n", (int)-ret, strerror(-ret) ); 448 exit(EXIT_FAILURE); 449 } 429 450 430 451 // Track the shutdown using a event_fd … … 445 466 // Submit all the answers we have and wait for responses 446 467 int ret = io_uring_submit_and_wait(ring, 1); 468 local.to_submit = 0; 447 469 448 470 // check errors … … 455 477 sqes += ret; 456 478 call++; 479 480 481 // eventfd_t val; 482 // ret = eventfd_read(blockfd, &val); 483 484 // // check errors 485 // if (ret < 0) { 486 // fprintf( stderr, "eventfd read error: (%d) %s\n", (int)errno, strerror(errno) ); 487 // exit(EXIT_FAILURE); 488 // } 457 489 458 490 struct io_uring_cqe *cqe; … … 466 498 break; 467 499 } 500 501 if(local.to_submit > 30) break; 468 502 469 503 auto req = (class connection *)cqe->user_data; … … 512 546 #include <pthread.h> // for pthreads 513 547 #include <signal.h> // for signal(SIGPIPE, SIG_IGN); 514 #include <sys/eventfd.h> // use for termination515 548 #include <sys/socket.h> // for sockets in general 516 549 #include <netinet/in.h> // for sockaddr_in, AF_INET
Note: See TracChangeset
for help on using the changeset viewer.