//////////////////////////////////////////////////////////////////////////// HttpSM::state_cache_open_write() This state is set by set_next_state() for a cache open write (SERVER_READ_CACHE_WRITE) /////////////////////////////////////////////////////////////////////
| 2457 | // |
| 2458 | ////////////////////////////////////////////////////////////////////////// |
| 2459 | int |
| 2460 | HttpSM::state_cache_open_write(int event, void *data) |
| 2461 | { |
| 2462 | STATE_ENTER(&HttpSM : state_cache_open_write, event); |
| 2463 | |
| 2464 | // Make sure we are on the "right" thread |
| 2465 | if (_ua.get_txn()) { |
| 2466 | pending_action = _ua.get_txn()->adjust_thread(this, event, data); |
| 2467 | if (!pending_action.empty()) { |
| 2468 | Metrics::Counter::increment(http_rsb.cache_open_write_adjust_thread); |
| 2469 | return 0; // Go away if we reschedule |
| 2470 | } |
| 2471 | NetVConnection *vc = _ua.get_txn()->get_netvc(); |
| 2472 | ink_release_assert(vc && vc->thread == this_ethread()); |
| 2473 | } |
| 2474 | |
| 2475 | pending_action.clear_if_action_is(reinterpret_cast<Action *>(data)); |
| 2476 | |
| 2477 | ATS_PROBE1(milestone_cache_open_write_end, sm_id); |
| 2478 | milestones[TS_MILESTONE_CACHE_OPEN_WRITE_END] = ink_get_hrtime(); |
| 2479 | pending_action = nullptr; |
| 2480 | |
| 2481 | switch (event) { |
| 2482 | case CACHE_EVENT_OPEN_WRITE: |
| 2483 | ////////////////////////////// |
| 2484 | // OPEN WRITE is successful // |
| 2485 | ////////////////////////////// |
| 2486 | t_state.cache_info.write_lock_state = HttpTransact::CACHE_WL_SUCCESS; |
| 2487 | break; |
| 2488 | |
| 2489 | case CACHE_EVENT_OPEN_WRITE_FAILED: |
| 2490 | // Failed on the write lock and retrying the vector |
| 2491 | // for reading |
| 2492 | if (t_state.redirect_info.redirect_in_process) { |
| 2493 | SMDbg(dbg_ctl_http_redirect, "CACHE_EVENT_OPEN_WRITE_FAILED during redirect follow"); |
| 2494 | t_state.cache_open_write_fail_action = CACHE_WL_FAIL_ACTION_DEFAULT; |
| 2495 | t_state.cache_info.write_lock_state = HttpTransact::CACHE_WL_FAIL; |
| 2496 | break; |
| 2497 | } |
| 2498 | if (t_state.txn_conf->cache_open_write_fail_action == CACHE_WL_FAIL_ACTION_DEFAULT) { |
| 2499 | t_state.cache_info.write_lock_state = HttpTransact::CACHE_WL_FAIL; |
| 2500 | break; |
| 2501 | } else { |
| 2502 | t_state.cache_open_write_fail_action = t_state.txn_conf->cache_open_write_fail_action; |
| 2503 | if (!t_state.cache_info.object_read || |
| 2504 | (t_state.cache_open_write_fail_action == CACHE_WL_FAIL_ACTION_ERROR_ON_MISS_OR_REVALIDATE)) { |
| 2505 | // cache miss, set wl_state to fail |
| 2506 | SMDbg(dbg_ctl_http, "cache object read %p, cache_wl_fail_action %d", t_state.cache_info.object_read, |
| 2507 | t_state.cache_open_write_fail_action); |
| 2508 | t_state.cache_info.write_lock_state = HttpTransact::CACHE_WL_FAIL; |
| 2509 | break; |
| 2510 | } |
| 2511 | } |
| 2512 | // INTENTIONAL FALL THROUGH |
| 2513 | // Allow for stale object to be served |
| 2514 | case CACHE_EVENT_OPEN_READ: |
| 2515 | if (!t_state.cache_info.object_read) { |
| 2516 | t_state.cache_open_write_fail_action = t_state.txn_conf->cache_open_write_fail_action; |
nothing calls this directly
no test coverage detected