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
34 changes: 34 additions & 0 deletions proxy/ProxySession.cc
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,37 @@ ProxySession::has_hooks() const
{
return this->api_hooks.has_hooks() || http_global_hooks->has_hooks();
}

void
ProxySession::add_to_active_queue()
{
UnixNetVConnection *vc = dynamic_cast<UnixNetVConnection *>(this->get_netvc());
if (vc) { // If it isn't a netvc, no active_queue to manage
if (mutex->thread_holding == this_ethread()) {
// Should be safe to blocking grab the nh mutex, probably already have it
// but will not in the direct schedule case
SCOPED_MUTEX_LOCK(lock, vc->nh->mutex, this_ethread());
vc->add_to_active_queue();
} else {
ink_release_assert(!"BUG: Trying to add vc to active_queue from non-owning thread");
}
}
}

void
ProxySession::add_to_keep_alive_queue()
{
UnixNetVConnection *vc = dynamic_cast<UnixNetVConnection *>(this->get_netvc());
if (vc) { // If it isn't a netvc, no keep_alive_queue to manage
if (vc->active_timeout_in == 0) {
if (vc && mutex->thread_holding == this_ethread()) {
// Should be safe to blocking grab the nh mutex, probably already have it
// but will not in the direct schedule case
SCOPED_MUTEX_LOCK(lock, vc->nh->mutex, this_ethread());
vc->add_to_keep_alive_queue();
} else {
ink_release_assert(!"BUG: Trying to add vc to keep_alive_queue from non-owning thread");
}
}
}
}
6 changes: 6 additions & 0 deletions proxy/ProxySession.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ class ProxySession : public VConnection

APIHook *hook_get(TSHttpHookID id) const;
HttpAPIHooks const *feature_hooks() const;

// Wrappers to grab appropriate locks and put
// the assocated netvc on the appropriate queue
void add_to_active_queue();
void add_to_keep_alive_queue();

////////////////////
// Members

Expand Down
4 changes: 2 additions & 2 deletions proxy/http/Http1ClientSession.cc
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ Http1ClientSession::release(ProxyTransaction *trans)

if (client_vc) {
client_vc->cancel_active_timeout();
client_vc->add_to_keep_alive_queue();
this->add_to_keep_alive_queue();
}
trans->destroy();
}
Expand All @@ -459,7 +459,7 @@ Http1ClientSession::new_transaction()
trans.set_proxy_ssn(this);
transact_count++;

client_vc->add_to_active_queue();
this->add_to_active_queue();
trans.new_transaction();
}

Expand Down
14 changes: 4 additions & 10 deletions proxy/http2/Http2ConnectionState.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ Http2ConnectionState::create_stream(Http2StreamId new_id, Http2Error &error)
new_stream->mutex = new_ProxyMutex();
new_stream->is_first_transaction_flag = get_stream_requests() == 0;
increment_stream_requests();
ua_session->get_netvc()->add_to_active_queue();
ua_session->add_to_active_queue();

return new_stream;
}
Expand Down Expand Up @@ -1264,10 +1264,7 @@ Http2ConnectionState::cleanup_streams()
if (!is_state_closed()) {
SCOPED_MUTEX_LOCK(lock, this->ua_session->mutex, this_ethread());

UnixNetVConnection *vc = static_cast<UnixNetVConnection *>(ua_session->get_netvc());
if (vc && vc->active_timeout_in == 0) {
vc->add_to_keep_alive_queue();
}
ua_session->add_to_keep_alive_queue();
}
}

Expand Down Expand Up @@ -1353,11 +1350,8 @@ Http2ConnectionState::release_stream(Http2Stream *stream)
// If the number of clients is 0, HTTP2_SESSION_EVENT_FINI is not received or sent, and ua_session is active,
// then mark the connection as inactive
ua_session->clear_session_active();
UnixNetVConnection *vc = static_cast<UnixNetVConnection *>(ua_session->get_netvc());
if (vc && vc->active_timeout_in == 0) {
// With heavy traffic, ua_session could be destroyed. Do not touch ua_session after this.
vc->add_to_keep_alive_queue();
}
// With heavy traffic, ua_session could be destroyed. Do not touch ua_session after this.
ua_session->add_to_keep_alive_queue();
} else {
schedule_zombie_event();
}
Expand Down