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

Function cache_op

src/iocore/aio/AIO.cc:446–483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

444}
445
446static inline int
447cache_op(AIOCallback *op)
448{
449 bool read = (op->aiocb.aio_lio_opcode == LIO_READ);
450 for (; op; op = op->then) {
451 ink_aiocb *a = &op->aiocb;
452 ssize_t err, res = 0;
453
454 while (a->aio_nbytes - res > 0) {
455 do {
456 if (read) {
457#ifdef AIO_FAULT_INJECTION
458 err = aioFaultInjection.pread(a->aio_fildes, (static_cast<char *>(a->aio_buf)) + res, a->aio_nbytes - res,
459 a->aio_offset + res);
460#else
461 err = pread(a->aio_fildes, (static_cast<char *>(a->aio_buf)) + res, a->aio_nbytes - res, a->aio_offset + res);
462#endif
463 } else {
464#ifdef AIO_FAULT_INJECTION
465 err = aioFaultInjection.pwrite(a->aio_fildes, (static_cast<char *>(a->aio_buf)) + res, a->aio_nbytes - res,
466 a->aio_offset + res);
467#else
468 err = pwrite(a->aio_fildes, (static_cast<char *>(a->aio_buf)) + res, a->aio_nbytes - res, a->aio_offset + res);
469#endif
470 }
471 } while ((err < 0) && (errno == EINTR || errno == ENOBUFS || errno == ENOMEM));
472 if (err <= 0) {
473 Warning("cache disk operation failed %s %zd %d\n", (a->aio_lio_opcode == LIO_READ) ? "READ" : "WRITE", err, errno);
474 op->aio_result = -errno;
475 return (err);
476 }
477 res += err;
478 }
479 op->aio_result = res;
480 ink_assert(op->ok());
481 }
482 return 1;
483}
484
485bool
486ink_aio_thread_num_set(int thread_num)

Callers 1

aio_thread_mainMethod · 0.85

Calls 3

preadMethod · 0.80
pwriteMethod · 0.80
okMethod · 0.45

Tested by

no test coverage detected