| 538 | } |
| 539 | |
| 540 | int |
| 541 | CacheVC::removeEvent(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */) |
| 542 | { |
| 543 | cancel_trigger(); |
| 544 | set_io_not_in_progress(); |
| 545 | { |
| 546 | MUTEX_TRY_LOCK(lock, stripe->mutex, mutex->thread_holding); |
| 547 | if (!lock.is_locked()) { |
| 548 | VC_SCHED_LOCK_RETRY(); |
| 549 | } |
| 550 | if (_action.cancelled) { |
| 551 | if (od) { |
| 552 | stripe->close_write(this); |
| 553 | od = nullptr; |
| 554 | } |
| 555 | goto Lfree; |
| 556 | } |
| 557 | if (!f.remove_aborted_writers) { |
| 558 | if (stripe->open_write(this, true, 1)) { |
| 559 | // writer exists |
| 560 | od = stripe->open_read(&key); |
| 561 | ink_release_assert(od); |
| 562 | od->dont_update_directory = true; |
| 563 | od = nullptr; |
| 564 | } else { |
| 565 | od->dont_update_directory = true; |
| 566 | } |
| 567 | f.remove_aborted_writers = 1; |
| 568 | } |
| 569 | Lread: |
| 570 | SET_HANDLER(&CacheVC::removeEvent); |
| 571 | if (!buf) { |
| 572 | goto Lcollision; |
| 573 | } |
| 574 | if (!stripe->dir_valid(&dir)) { |
| 575 | last_collision = nullptr; |
| 576 | goto Lcollision; |
| 577 | } |
| 578 | // check read completed correct FIXME: remove bad vols |
| 579 | if (!io.ok()) { |
| 580 | goto Ldone; |
| 581 | } |
| 582 | { |
| 583 | // verify that this is our document |
| 584 | Doc *doc = reinterpret_cast<Doc *>(buf->data()); |
| 585 | /* should be first_key not key..right?? */ |
| 586 | if (doc->first_key == key) { |
| 587 | ink_assert(doc->magic == DOC_MAGIC); |
| 588 | if (dir_delete(&key, stripe, &dir) > 0) { |
| 589 | if (od) { |
| 590 | stripe->close_write(this); |
| 591 | } |
| 592 | od = nullptr; |
| 593 | goto Lremoved; |
| 594 | } |
| 595 | goto Ldone; |
| 596 | } |
| 597 | } |
no test coverage detected