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
18 changes: 15 additions & 3 deletions proxy/http2/Http2ConnectionState.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
#include "tscpp/util/PostScript.h"
#include "tscpp/util/LocalBuffer.h"

#include <sstream>
#include <algorithm>
#include <numeric>
#include <sstream>

#define REMEMBER(e, r) \
{ \
Expand Down Expand Up @@ -1197,6 +1198,9 @@ Http2ConnectionState::destroy()
if (zombie_event) {
zombie_event->cancel();
}
for (auto *event : _xmit_events) {
event->cancel();
}
// release the mutex after the events are cancelled and sessions are destroyed.
mutex = nullptr; // magic happens - assigning to nullptr frees the ProxyMutex
}
Expand Down Expand Up @@ -1280,6 +1284,10 @@ Http2ConnectionState::main_event_handler(int event, void *edata)
} else if (edata == fini_event) {
fini_event = nullptr;
}
if (auto const xmit_event = std::find(_xmit_events.begin(), _xmit_events.end(), static_cast<Event *>(edata));
xmit_event != _xmit_events.end()) {
_xmit_events.erase(xmit_event);
}
++recursion;
switch (event) {
// Finalize HTTP/2 Connection
Expand Down Expand Up @@ -1383,6 +1391,10 @@ Http2ConnectionState::state_closed(int event, void *edata)
} else if (edata == shutdown_cont_event) {
shutdown_cont_event = nullptr;
}
if (auto const xmit_event = std::find(_xmit_events.begin(), _xmit_events.end(), static_cast<Event *>(edata));
xmit_event != _xmit_events.end()) {
_xmit_events.erase(xmit_event);
}
return 0;
}

Expand Down Expand Up @@ -1702,7 +1714,7 @@ Http2ConnectionState::schedule_stream(Http2Stream *stream)
_scheduled = true;

SET_HANDLER(&Http2ConnectionState::main_event_handler);
this_ethread()->schedule_imm_local((Continuation *)this, HTTP2_SESSION_EVENT_XMIT);
_xmit_events.push_back(this_ethread()->schedule_imm_local((Continuation *)this, HTTP2_SESSION_EVENT_XMIT));
}
}

Expand Down Expand Up @@ -1747,7 +1759,7 @@ Http2ConnectionState::send_data_frames_depends_on_priority()
break;
}

this_ethread()->schedule_imm_local((Continuation *)this, HTTP2_SESSION_EVENT_XMIT);
_xmit_events.push_back(this_ethread()->schedule_imm_local((Continuation *)this, HTTP2_SESSION_EVENT_XMIT));
return;
}

Expand Down
2 changes: 2 additions & 0 deletions proxy/http2/Http2ConnectionState.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#pragma once

#include <atomic>
#include <vector>

#include "NetTimeout.h"

Expand Down Expand Up @@ -242,6 +243,7 @@ class Http2ConnectionState : public Continuation
Event *shutdown_cont_event = nullptr;
Event *fini_event = nullptr;
Event *zombie_event = nullptr;
std::vector<Event *> _xmit_events;
Comment thread
bneradt marked this conversation as resolved.
};

///////////////////////////////////////////////
Expand Down