Skip to content
Closed
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
46 changes: 9 additions & 37 deletions proxy/http/HttpCacheSM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,6 @@
Debug("http_cache", "[%" PRId64 "] [%s, %s]", master_sm->sm_id, #state_name, HttpDebugNames::get_event_name(event)); \
}

HttpCacheAction::HttpCacheAction() {}

void
HttpCacheAction::cancel(Continuation *c)
{
ink_assert(c == nullptr || c == sm->master_sm);
ink_assert(this->cancelled == 0);

this->cancelled = 1;
if (sm->pending_action) {
sm->pending_action->cancel();
}
}

HttpCacheSM::HttpCacheSM()
: Continuation(nullptr),

captive_action()

{
}

//////////////////////////////////////////////////////////////////////////
//
// HttpCacheSM::state_cache_open_read()
Expand Down Expand Up @@ -98,7 +76,6 @@ int
HttpCacheSM::state_cache_open_read(int event, void *data)
{
STATE_ENTER(&HttpCacheSM::state_cache_open_read, event);
ink_assert(captive_action.cancelled == 0);
pending_action = nullptr;

switch (event) {
Expand Down Expand Up @@ -158,7 +135,6 @@ int
HttpCacheSM::state_cache_open_write(int event, void *data)
{
STATE_ENTER(&HttpCacheSM::state_cache_open_write, event);
ink_assert(captive_action.cancelled == 0);
pending_action = nullptr;
bool read_retry_on_write_fail = false;

Expand Down Expand Up @@ -196,8 +172,6 @@ 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 Down Expand Up @@ -266,24 +240,23 @@ 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);

if (action_handle != ACTION_RESULT_DONE) {
pending_action = action_handle;
}

// Check to see if we've already called the user back
// If we have then it's ACTION_RESULT_DONE, other wise
// return our captive action and ensure that we are actually
// doing something useful
// If we have then it's ACTION_RESULT_DONE, otherwise
// return the cacheProcessor action
if (open_read_cb == true) {
ink_release_assert(action_handle == ACTION_RESULT_DONE);
return ACTION_RESULT_DONE;
} else {
ink_assert(pending_action != nullptr || write_locked == true);
return &captive_action;
return pending_action == nullptr ? ACTION_RESULT_DONE : pending_action;
}
}

Expand Down Expand Up @@ -368,13 +341,12 @@ HttpCacheSM::open_write(const HttpCacheKey *key, URL *url, HTTPHdr *request, Cac
pending_action = action_handle;
}
// Check to see if we've already called the user back
// If we have then it's ACTION_RESULT_DONE, other wise
// return our captive action and ensure that we are actually
// doing something useful
// If we have then it's ACTION_RESULT_DONE, otherwise
// return the action from the cacheProcessor
if (open_write_cb == true) {
ink_release_assert(action_handle == ACTION_RESULT_DONE);
return ACTION_RESULT_DONE;
} else {
ink_assert(pending_action != nullptr);
return &captive_action;
return pending_action == nullptr ? ACTION_RESULT_DONE : pending_action;
}
}
15 changes: 1 addition & 14 deletions proxy/http/HttpCacheSM.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,16 @@
class HttpSM;
class HttpCacheSM;

struct HttpCacheAction : public Action {
HttpCacheAction();
void cancel(Continuation *c = nullptr) override;
void
init(HttpCacheSM *sm_arg)
{
sm = sm_arg;
};
HttpCacheSM *sm = nullptr;
};

class HttpCacheSM : public Continuation
{
public:
HttpCacheSM();
HttpCacheSM() : Continuation(nullptr) {}

void
init(HttpSM *sm_arg, Ptr<ProxyMutex> &amutex)
{
master_sm = sm_arg;
mutex = amutex;
captive_action.init(this);
}

Action *open_read(const HttpCacheKey *key, URL *url, HTTPHdr *hdr, const OverridableHttpConfigParams *params,
Expand Down Expand Up @@ -202,7 +190,6 @@ class HttpCacheSM : public Continuation
int state_cache_open_read(int event, void *data);
int state_cache_open_write(int event, void *data);

HttpCacheAction captive_action;
bool open_read_cb = false;
bool open_write_cb = false;

Expand Down