MCPcopy Create free account
hub / github.com/apache/trafficserver / aio_thread_main

Method aio_thread_main

src/iocore/aio/AIO.cc:496–550  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

494}
495
496void *
497AIOThreadInfo::aio_thread_main(AIOThreadInfo *thr_info)
498{
499 AIO_Reqs *my_aio_req = thr_info->req;
500 AIOCallback *op = nullptr;
501 ink_mutex_acquire(&my_aio_req->aio_mutex);
502 for (;;) {
503 do {
504 if (TSSystemState::is_event_system_shut_down()) {
505 ink_mutex_release(&my_aio_req->aio_mutex);
506 return nullptr;
507 }
508 /* check if any pending requests on the atomic list */
509 aio_move(my_aio_req);
510 if (!(op = my_aio_req->aio_todo.pop())) {
511 break;
512 }
513#ifdef AIO_STATS
514 num_requests--;
515 my_aio_req->queued--;
516 ink_atomic_increment(&my_aio_req->pending, 1);
517#endif
518 ink_mutex_release(&my_aio_req->aio_mutex);
519
520 // update the stats;
521 if (op->aiocb.aio_lio_opcode == LIO_WRITE) {
522 ts::Metrics::Counter::increment(aio_rsb.write_count);
523 ts::Metrics::Counter::increment(aio_rsb.kb_write, op->aiocb.aio_nbytes >> 10);
524 } else {
525 ts::Metrics::Counter::increment(aio_rsb.read_count);
526 ts::Metrics::Counter::increment(aio_rsb.kb_read, op->aiocb.aio_nbytes >> 10);
527 }
528 cache_op(reinterpret_cast<AIOCallback *>(op));
529 ink_atomic_increment(&my_aio_req->requests_queued, -1);
530#ifdef AIO_STATS
531 ink_atomic_increment(&my_aio_req->pending, -1);
532#endif
533 op->link.prev = nullptr;
534 op->link.next = nullptr;
535 op->mutex = op->action.mutex;
536 if (op->thread == AIO_CALLBACK_THREAD_AIO) {
537 SCOPED_MUTEX_LOCK(lock, op->mutex, thr_info->mutex->thread_holding);
538 op->handleEvent(EVENT_NONE, nullptr);
539 } else if (op->thread == AIO_CALLBACK_THREAD_ANY) {
540 eventProcessor.schedule_imm(op);
541 } else {
542 op->thread->schedule_imm(op);
543 }
544 ink_mutex_acquire(&my_aio_req->aio_mutex);
545 } while (true);
546 timespec timedwait_msec = ink_hrtime_to_timespec(ink_get_hrtime() + HRTIME_MSECONDS(EThread::default_wait_interval_ms));
547 ink_cond_timedwait(&my_aio_req->aio_cond, &my_aio_req->aio_mutex, &timedwait_msec);
548 }
549 return nullptr;
550}
551
552#if TS_USE_LINUX_IO_URING
553#include "iocore/io_uring/IO_URING.h"

Callers

nothing calls this directly

Calls 12

ink_mutex_acquireFunction · 0.85
ink_mutex_releaseFunction · 0.85
aio_moveFunction · 0.85
ink_atomic_incrementFunction · 0.85
incrementFunction · 0.85
cache_opFunction · 0.85
ink_hrtime_to_timespecFunction · 0.85
ink_get_hrtimeFunction · 0.85
ink_cond_timedwaitFunction · 0.85
popMethod · 0.45
handleEventMethod · 0.45
schedule_immMethod · 0.45

Tested by

no test coverage detected