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

Method scanObject

src/iocore/cache/CacheVC.cc:666–895  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

664}
665
666int
667CacheVC::scanObject(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
668{
669 Dbg(dbg_ctl_cache_scan_truss, "inside %p:scanObject", this);
670
671 Doc *doc = nullptr;
672 void *result = nullptr;
673 int hlen = 0;
674 char hname[500];
675 bool hostinfo_copied = false;
676 off_t next_object_len = 0;
677 bool might_need_overlap_read = false;
678
679 cancel_trigger();
680 set_io_not_in_progress();
681 if (_action.cancelled) {
682 return free_CacheVC(this);
683 }
684
685 CACHE_TRY_LOCK(lock, stripe->mutex, mutex->thread_holding);
686 if (!lock.is_locked()) {
687 Dbg(dbg_ctl_cache_scan_truss, "delay %p:scanObject", this);
688 mutex->thread_holding->schedule_in_local(this, HRTIME_MSECONDS(cache_config_mutex_retry_delay));
689 return EVENT_CONT;
690 }
691
692 if (!fragment) { // initialize for first read
693 fragment = 1;
694 scan_stripe_map = make_vol_map(stripe);
695 io.aiocb.aio_offset = next_in_map(stripe, scan_stripe_map, stripe->vol_offset_to_offset(0));
696 if (io.aiocb.aio_offset >= static_cast<off_t>(stripe->skip + stripe->len)) {
697 goto Lnext_vol;
698 }
699 io.aiocb.aio_nbytes = SCAN_BUF_SIZE;
700 io.aiocb.aio_buf = buf->data();
701 io.action = this;
702 io.thread = AIO_CALLBACK_THREAD_ANY;
703 Dbg(dbg_ctl_cache_scan_truss, "read %p:scanObject", this);
704 goto Lread;
705 }
706
707 if (!io.ok()) {
708 result = reinterpret_cast<void *>(-ECACHE_READ_FAIL);
709 goto Ldone;
710 }
711
712 doc = reinterpret_cast<Doc *>(buf->data() + offset);
713 // If there is data in the buffer before the start that is from a partial object read previously
714 // Fix things as if we read it this time.
715 if (scan_fix_buffer_offset) {
716 io.aio_result += scan_fix_buffer_offset;
717 io.aiocb.aio_nbytes += scan_fix_buffer_offset;
718 io.aiocb.aio_offset -= scan_fix_buffer_offset;
719 io.aiocb.aio_buf = static_cast<char *>(io.aiocb.aio_buf) - scan_fix_buffer_offset;
720 scan_fix_buffer_offset = 0;
721 }
722 while (static_cast<off_t>(reinterpret_cast<char *>(doc) - buf->data()) + next_object_len <
723 static_cast<off_t>(io.aiocb.aio_nbytes)) {

Callers

nothing calls this directly

Calls 15

load_http_infoMethod · 0.95
free_CacheVCFunction · 0.85
make_vol_mapFunction · 0.85
next_in_mapFunction · 0.85
dir_probeFunction · 0.85
ink_aio_readFunction · 0.85
schedule_in_localMethod · 0.80
vol_offset_to_offsetMethod · 0.80
round_to_approx_sizeMethod · 0.80
dir_agg_validMethod · 0.80
vol_offsetMethod · 0.80
request_getMethod · 0.80

Tested by

no test coverage detected