8000 This is a sub-PR to suggest some changes. by neunhoef · Pull Request #12495 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

This is a sub-PR to suggest some changes. #12495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 24, 2020
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
1 change: 1 addition & 0 deletions 3rdParty/fuerte/src/GeneralConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class GeneralConnection : public fuerte::Connection {

void startConnection() {
// start connecting only if state is disconnected
FUERTE_ASSERT(this->_active.load());
Connection::State exp = Connection::State::Created;
if (_state.compare_exchange_strong(exp, Connection::State::Connecting)) {
FUERTE_LOG_DEBUG << "startConnection: this=" << this << "\n";
Expand Down
9 changes: 4 additions & 5 deletions 3rdParty/fuerte/src/H1Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ void H1Connection<ST>::asyncWriteNextRequest() {
FUERTE_LOG_HTTPTRACE << "asyncWriteNextRequest: this=" << this << "\n";
FUERTE_ASSERT(this->_active.load());
auto state = this->_state.load();
FUERTE_ASSERT(state == Connection::State::Connected ||
state == Connection::State::Closed);
FUERTE_ASSERT(state == Connection::State::Connected);
FUERTE_ASSERT(_item == nullptr);

RequestItem* ptr = nullptr;
Expand Down Expand Up @@ -335,10 +334,11 @@ template <SocketType ST>
void H1Connection<ST>::asyncWriteCallback(asio_ns::error_code const& ec,
size_t nwrite) {
FUERTE_ASSERT(this->_writing);
// In the TLS case a connection can go to Failed state essentially at any time
// A connection can go to Closed state essentially at any time
// and in this case _active will already be false if we get back here. Therefore
// we cannot assert on it being true, which would otherwise be correct.
FUERTE_ASSERT(this->_state != Connection::State::Connecting);
FUERTE_ASSERT(this->_state == Connection::State::Connected ||
this->_state == Connection::State::Closed);
this->_writing = false; // indicate that no async write is ongoing any more
this->_proto.timer.cancel(); // cancel alarm for timeout

Expand Down Expand Up @@ -382,7 +382,6 @@ void H1Connection<ST>::asyncReadCallback(asio_ns::error_code const& ec) {
FUERTE_LOG_DEBUG << "asyncReadCallback: Error while reading from socket: '"
<< ec.message() << "' , this=" << this << "\n";

// Restart connection, will invoke _item cb
this->shutdownConnection(this->translateError(ec, Error::ReadError));
return;
}
Expand Down
32 changes: 0 additions & 32 deletions 3rdParty/fuerte/src/H1Connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,38 +124,6 @@ class H1Connection final : public fuerte::GeneralConnection<ST, RequestItem> {
http_parser _parser;
http_parser_settings _parserSettings;

std::atomic<int> _leased;
// This member is used to allow to lease a connection from the connection
// pool without the idle alarm going off when we believe to have
// leased the connection successfully. Here is the workflow:
// Normally, the value is 0. If the idle alarm goes off, it first
// compare-exchanges this value from 0 to -1, then shuts down the
// connection (setting the _state to Failed in the TLS case). After
// that, the value is set back to 0.
// The lease operation tries to compare-exchange the value from 0 to 1,
// and if this has worked, it checks again that the _state is not Failed.
// This means, that if a lease has happened successfully, the idle alarm
// does no longer shut down the connection.
// If `sendRequest` is called on the connection (typically after a lease),
// a compare-exchange operation from 1 to 2 is tried. The value 2 indicates
// that the next time the idle alarm is set (after write/read activity
// finishes), a compare-exchange to 0 happens, such that the idle alarm
// can happen again.
// All this has the net effect that from the moment of a successful lease
// until the next call to `sendRequest`, we are sure that the idle alarm
// does not go off.
// Note that if one does not lease the connection, the idle alarm can
// go off at any time and the next `sendRequest` might fail because of
// this.
// Furthermore, note that if one leases the connection and does not call
// `sendRequest`, then the idle alarm does no longer go off and the
// connection stays open indefinitely. This is misusage.
// Finally, note that if the idle alarm goes off between a lease and
// the following call to `sendRequest`, the connection might stay open
// indefinitely, until activity on the connection has ceased again
// and a new idle alarm is set. However, this will automatically happen
// if that `sendRequest` and the corresponding request finishes.

// parser state
std::string _lastHeaderField;
std::string _lastHeaderValue;
Expand Down
23 changes: 0 additions & 23 deletions 3rdParty/fuerte/src/H2Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,29 +458,6 @@ void H2Connection<SocketType::Ssl>::finishConnect() {
// Writing data
// ------------------------------------

// Thread-Safe: activate the writer loop (if off and items are queud)
//template <SocketType T>
//void H2Connection<T>::startWriting() {
// FUERTE_ASSERT(this->_state.load(std::memory_order_acquire) ==
// Connection::State::Connected);
// FUERTE_LOG_HTTPTRACE << "startWriting: this=" << this << "\n";
// bool tmp = _signaledWrite.load();
// if (!tmp && !_signaledWrite.exchange(true)) {
// this->_io_context->post([self = Connection::shared_from_this(), this] {
// _signaledWrite.store(false);
// // we have been in a race with shutdownConnection()
// Connection::State state = this->_state.load();
// if (state != Connection::State::Connected) {
// if (state == Connection::State::Disconnected) {
// this->startConnection();
// }
// } else {
// this->doWrite();
// }
// });
// }
//}

// queue the response onto the session, call only on IO thread
template <SocketType T>
void H2Connection<T>::queueHttp2Requests() {
Expand Down
0