openWriteStartDone handles vector read (addition of alternates) and lock misses
| 665 | // openWriteStartDone handles vector read (addition of alternates) |
| 666 | // and lock misses |
| 667 | int |
| 668 | CacheVC::openWriteStartDone(int event, Event *e) |
| 669 | { |
| 670 | intptr_t err = ECACHE_NO_DOC; |
| 671 | cancel_trigger(); |
| 672 | if (is_io_in_progress()) { |
| 673 | if (event != AIO_EVENT_DONE) { |
| 674 | return EVENT_CONT; |
| 675 | } |
| 676 | set_io_not_in_progress(); |
| 677 | } |
| 678 | { |
| 679 | CACHE_TRY_LOCK(lock, stripe->mutex, mutex->thread_holding); |
| 680 | if (!lock.is_locked()) { |
| 681 | VC_LOCK_RETRY_EVENT(); |
| 682 | } |
| 683 | |
| 684 | if (_action.cancelled && (!od || !od->has_multiple_writers())) { |
| 685 | goto Lcancel; |
| 686 | } |
| 687 | |
| 688 | if (event == AIO_EVENT_DONE) { // vector read done |
| 689 | Doc *doc = reinterpret_cast<Doc *>(buf->data()); |
| 690 | if (!io.ok()) { |
| 691 | err = ECACHE_READ_FAIL; |
| 692 | goto Lfailure; |
| 693 | } |
| 694 | |
| 695 | /* INKqa07123. |
| 696 | A directory entry which is no longer valid may have been overwritten. |
| 697 | We need to start afresh from the beginning by setting last_collision |
| 698 | to nullptr. |
| 699 | */ |
| 700 | if (!stripe->dir_valid(&dir)) { |
| 701 | DDbg(dbg_ctl_cache_write, "OpenReadStartDone: Dir not valid: Write Head: %" PRId64 ", Dir: %" PRId64, |
| 702 | (int64_t)stripe->offset_to_vol_offset(stripe->directory.header->write_pos), dir_offset(&dir)); |
| 703 | last_collision = nullptr; |
| 704 | goto Lcollision; |
| 705 | } |
| 706 | if (!(doc->first_key == first_key)) { |
| 707 | goto Lcollision; |
| 708 | } |
| 709 | |
| 710 | if (doc->magic != DOC_MAGIC || !doc->hlen || this->load_http_info(write_vector, doc, buf.object()) != doc->hlen) { |
| 711 | err = ECACHE_BAD_META_DATA; |
| 712 | goto Lfailure; |
| 713 | } |
| 714 | ink_assert(write_vector->count() > 0); |
| 715 | od->first_dir = dir; |
| 716 | first_dir = dir; |
| 717 | if (doc->single_fragment()) { |
| 718 | // fragment is tied to the vector |
| 719 | od->move_resident_alt = true; |
| 720 | od->single_doc_key = doc->key; |
| 721 | dir_assign(&od->single_doc_dir, &dir); |
| 722 | dir_set_tag(&od->single_doc_dir, od->single_doc_key.slice32(2)); |
| 723 | } |
| 724 | first_buf = buf; |
nothing calls this directly
no test coverage detected