Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 12 additions & 19 deletions proxy/http/HttpCacheSM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ HttpCacheSM::state_cache_open_read(int event, void *data)
ink_assert(captive_action.cancelled == 0);
pending_action = nullptr;

if (captive_action.cancelled == 1) {
return VC_EVENT_CONT; // SM gave up on us
}

switch (event) {
case CACHE_EVENT_OPEN_READ:
HTTP_INCREMENT_DYN_STAT(http_current_cache_connections_stat);
Expand All @@ -115,11 +111,10 @@ HttpCacheSM::state_cache_open_read(int event, void *data)
}
open_read_cb = true;
cache_read_vc = static_cast<CacheVConnection *>(data);
master_sm->handleEvent(event, &captive_action);
master_sm->handleEvent(event, data);
break;

case CACHE_EVENT_OPEN_READ_FAILED:
err_code = reinterpret_cast<intptr_t>(data);
if ((intptr_t)data == -ECACHE_DOC_BUSY) {
// Somebody else is writing the object
if (open_read_tries <= master_sm->t_state.txn_conf->max_cache_open_read_retries) {
Expand All @@ -130,12 +125,12 @@ HttpCacheSM::state_cache_open_read(int event, void *data)
// Give up; the update didn't finish in time
// HttpSM will inform HttpTransact to 'proxy-only'
open_read_cb = true;
master_sm->handleEvent(event, &captive_action);
master_sm->handleEvent(event, data);
}
} else {
// Simple miss in the cache.
open_read_cb = true;
master_sm->handleEvent(event, &captive_action);
master_sm->handleEvent(event, data);
}
break;

Expand Down Expand Up @@ -166,9 +161,6 @@ HttpCacheSM::state_cache_open_write(int event, void *data)
ink_assert(captive_action.cancelled == 0);
pending_action = nullptr;

if (captive_action.cancelled == 1) {
return VC_EVENT_CONT; // SM gave up on us
}
bool read_retry_on_write_fail = false;

switch (event) {
Expand All @@ -177,7 +169,7 @@ HttpCacheSM::state_cache_open_write(int event, void *data)
ink_assert(cache_write_vc == nullptr);
cache_write_vc = static_cast<CacheVConnection *>(data);
open_write_cb = true;
master_sm->handleEvent(event, &captive_action);
master_sm->handleEvent(event, data);
break;

case CACHE_EVENT_OPEN_WRITE_FAILED:
Expand Down Expand Up @@ -205,6 +197,8 @@ HttpCacheSM::state_cache_open_write(int event, void *data)
if (read_retry_on_write_fail || open_write_tries <= master_sm->t_state.txn_conf->max_cache_open_write_retries) {
// Retry open write;
open_write_cb = false;
// reset captive_action since HttpSM cancelled it
captive_action.cancelled = 0;
do_schedule_in();
} else {
// The cache is hosed or full or something.
Expand All @@ -214,8 +208,7 @@ HttpCacheSM::state_cache_open_write(int event, void *data)
"done retrying...",
master_sm->sm_id, open_write_tries);
open_write_cb = true;
err_code = reinterpret_cast<intptr_t>(data);
master_sm->handleEvent(event, &captive_action);
master_sm->handleEvent(event, data);
}
break;

Expand All @@ -226,7 +219,7 @@ HttpCacheSM::state_cache_open_write(int event, void *data)
"falling back to read retry...",
master_sm->sm_id, open_write_tries);
open_read_cb = false;
master_sm->handleEvent(CACHE_EVENT_OPEN_READ, &captive_action);
master_sm->handleEvent(CACHE_EVENT_OPEN_READ, data);
} else {
Debug("http_cache",
"[%" PRId64 "] [state_cache_open_write] cache open write failure %d. "
Expand Down Expand Up @@ -274,6 +267,8 @@ HttpCacheSM::do_cache_open_read(const HttpCacheKey &key)
} else {
ink_assert(open_read_cb == false);
}
// reset captive_action since HttpSM cancelled it during open read retry
captive_action.cancelled = 0;
// Initialising read-while-write-inprogress flag
this->readwhilewrite_inprogress = false;
Action *action_handle = cacheProcessor.open_read(this, &key, this->read_request_hdr, this->http_params, this->read_pin_in_cache);
Expand All @@ -289,7 +284,6 @@ HttpCacheSM::do_cache_open_read(const HttpCacheKey &key)
return ACTION_RESULT_DONE;
} else {
ink_assert(pending_action != nullptr || write_locked == true);
captive_action.cancelled = 0; // Make sure not cancelled before we hand it out
return &captive_action;
}
}
Expand Down Expand Up @@ -360,10 +354,10 @@ HttpCacheSM::open_write(const HttpCacheKey *key, URL *url, HTTPHdr *request, Cac
// a new write (could happen on a very busy document
// that must be revalidated every time)
// Changed by YTS Team, yamsat Plugin
// two criteria, either write retries over the amount OR timeout
if (open_write_tries > master_sm->redirection_tries &&
open_write_tries > master_sm->t_state.txn_conf->max_cache_open_write_retries) {
err_code = -ECACHE_DOC_BUSY;
master_sm->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, &captive_action);
master_sm->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *)-ECACHE_DOC_BUSY);
return ACTION_RESULT_DONE;
}

Expand All @@ -383,7 +377,6 @@ HttpCacheSM::open_write(const HttpCacheKey *key, URL *url, HTTPHdr *request, Cac
return ACTION_RESULT_DONE;
} else {
ink_assert(pending_action != nullptr);
captive_action.cancelled = 0; // Make sure not cancelled before we hand it out
return &captive_action;
}
}
9 changes: 0 additions & 9 deletions proxy/http/HttpCacheSM.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,6 @@ class HttpCacheSM : public Continuation
abort_write();
}

inline int
get_last_error() const
{
return err_code;
}

private:
void do_schedule_in();
Action *do_cache_open_read(const HttpCacheKey &);
Expand Down Expand Up @@ -235,7 +229,4 @@ class HttpCacheSM : public Continuation
// to keep track of multiple cache lookups
int lookup_max_recursive = 0;
int current_lookup_level = 0;

// last error from the cache subsystem
int err_code = 0;
};
Loading