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

Method state_cache_open_write

src/proxy/http/HttpSM.cc:2459–2563  ·  view source on GitHub ↗

//////////////////////////////////////////////////////////////////////////// HttpSM::state_cache_open_write() This state is set by set_next_state() for a cache open write (SERVER_READ_CACHE_WRITE) /////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

2457//
2458//////////////////////////////////////////////////////////////////////////
2459int
2460HttpSM::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;

Callers

nothing calls this directly

Calls 10

incrementFunction · 0.85
this_ethreadFunction · 0.85
ink_get_hrtimeFunction · 0.85
get_txnMethod · 0.80
adjust_threadMethod · 0.80
clear_if_action_isMethod · 0.80
get_http_infoMethod · 0.80
emptyMethod · 0.45
get_netvcMethod · 0.45
is_ram_cache_hitMethod · 0.45

Tested by

no test coverage detected