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

Method openReadFromWriterMain

src/iocore/cache/CacheRead.cc:369–414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

367}
368
369int
370CacheVC::openReadFromWriterMain(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
371{
372 cancel_trigger();
373 if (seek_to) {
374 vio.ndone = seek_to;
375 seek_to = 0;
376 }
377 IOBufferBlock *b = nullptr;
378 int64_t ntodo = vio.ntodo();
379 if (ntodo <= 0) {
380 return EVENT_CONT;
381 }
382 if (length < (static_cast<int64_t>(doc_len)) - vio.ndone) {
383 DDbg(dbg_ctl_cache_read_agg, "truncation %X", first_key.slice32(1));
384 if (is_action_tag_set("cache")) {
385 ink_release_assert(false);
386 }
387 Warning("Document %X truncated at %" PRId64 " of %" PRIu64 ", reading from writer", first_key.slice32(1), vio.ndone, doc_len);
388 return calluser(VC_EVENT_ERROR);
389 }
390 /* its possible that the user did a do_io_close before
391 openWriteWriteDone was called. */
392 if (length > (static_cast<int64_t>(doc_len)) - vio.ndone) {
393 int64_t skip_bytes = length - (doc_len - vio.ndone);
394 iobufferblock_skip(writer_buf.get(), &writer_offset, &length, skip_bytes);
395 }
396 int64_t bytes = length;
397 if (bytes > vio.ntodo()) {
398 bytes = vio.ntodo();
399 }
400 if (vio.ndone >= static_cast<int64_t>(doc_len)) {
401 ink_assert(bytes <= 0);
402 // reached the end of the document and the user still wants more
403 return calluser(VC_EVENT_EOS);
404 }
405 b = iobufferblock_clone(writer_buf.get(), writer_offset, bytes);
406 writer_buf = iobufferblock_skip(writer_buf.get(), &writer_offset, &length, bytes);
407 vio.get_writer()->append_block(b);
408 vio.ndone += bytes;
409 if (vio.ntodo() <= 0) {
410 return calluser(VC_EVENT_READ_COMPLETE);
411 } else {
412 return calluser(VC_EVENT_READ_READY);
413 }
414}
415
416int
417CacheVC::openReadClose(int event, Event * /* e ATS_UNUSED */)

Callers

nothing calls this directly

Calls 4

ntodoMethod · 0.80
get_writerMethod · 0.80
getMethod · 0.45
append_blockMethod · 0.45

Tested by

no test coverage detected