Skip to content
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

boostification of req session finished signal #47909

Merged
merged 5 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
10 changes: 4 additions & 6 deletions src/cpp/proxy/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class Engine::Private : public QObject
struct RequestSessionConnections {
Connection inspectedConnection;
Connection inspectErrorConnection;
Connection finishedConnection;
Connection finishedByAcceptConnection;
};

Expand Down Expand Up @@ -450,6 +451,7 @@ class Engine::Private : public QObject

// proxysession will take it from here
// TODO: use callbacks for performance
reqSessionConnectionMap.erase(rs);
rs->disconnect(this);

ps->add(rs);
Expand Down Expand Up @@ -612,10 +614,10 @@ class Engine::Private : public QObject
rs->setAutoShare(autoShare);

// TODO: use callbacks for performance
connect(rs, &RequestSession::finished, this, &Private::rs_finished);
reqSessionConnectionMap[rs] = {
rs->inspected.connect(boost::bind(&Private::rs_inspected, this, boost::placeholders::_1, rs)),
rs->inspectError.connect(boost::bind(&Private::rs_inspectError, this, rs)),
rs->finished.connect(boost::bind(&Private::rs_finished, this, rs)),
rs->finishedByAccept.connect(boost::bind(&Private::rs_finishedByAccept, this, rs))
};

Expand Down Expand Up @@ -760,11 +762,8 @@ class Engine::Private : public QObject
doProxy(rs, &idata);
}

private slots:
void rs_finished()
void rs_finished(RequestSession *rs)
{
RequestSession *rs = (RequestSession *)sender();

if(!rs->isSockJs())
logFinished(rs);

Expand All @@ -775,7 +774,6 @@ private slots:
tryTakeNext();
}

private:
void rs_finishedByAccept(RequestSession *rs)
{
logFinished(rs, true);
Expand Down
9 changes: 3 additions & 6 deletions src/cpp/proxy/proxysession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class ProxySession::Private : public QObject
Connection bytesWrittenConnection;
Connection errorRespondingConnection;
Connection pausedConnection;
Connection finishedConnection;
Connection headerBytesSentConnection;
Connection bodyBytesSentConnection;
};
Expand Down Expand Up @@ -254,11 +255,11 @@ class ProxySession::Private : public QObject

sessionItems += si;
sessionItemsBySession.insert(rs, si);
connect(rs, &RequestSession::finished, this, &Private::rs_finished);
reqSessionConnectionMap[rs] = {
rs->bytesWritten.connect(boost::bind(&Private::rs_bytesWritten, this, boost::placeholders::_1, rs)),
rs->errorResponding.connect(boost::bind(&Private::rs_errorResponding, this, rs)),
rs->paused.connect(boost::bind(&Private::rs_paused, this, rs)),
rs->finished.connect(boost::bind(&Private::rs_finished, this, rs)),
rs->headerBytesSent.connect(boost::bind(&Private::rs_headerBytesSent, this, boost::placeholders::_1, rs)),
rs->bodyBytesSent.connect(boost::bind(&Private::rs_bodyBytesSent, this, boost::placeholders::_1, rs))
};
Expand Down Expand Up @@ -1189,7 +1190,6 @@ class ProxySession::Private : public QObject
}
}

public slots:
void rs_bytesWritten(int count, RequestSession *rs)
{
log_debug("proxysession: %p response bytes written id=%s: %d", q, rs->rid().second.data(), count);
Expand All @@ -1207,10 +1207,8 @@ public slots:
tryResponseRead();
}

void rs_finished()
void rs_finished(RequestSession *rs)
{
RequestSession *rs = (RequestSession *)sender();

log_debug("proxysession: %p response finished id=%s", q, rs->rid().second.data());

SessionItem *si = sessionItemsBySession.value(rs);
Expand Down Expand Up @@ -1386,7 +1384,6 @@ public slots:
incCounter(Stats::ClientContentBytesSent, count);
}

public:
void acceptRequest_finished()
{
if(acceptRequest->success())
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/proxy/requestsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ class RequestSession::Private : public QObject
if(zhttpRequest->isFinished())
{
cleanup();
emit q->finished();
q->finished();
}
}

Expand Down Expand Up @@ -877,7 +877,7 @@ class RequestSession::Private : public QObject
{
log_debug("requestsession: request error id=%s", rid.second.data());
cleanup();
emit q->finished();
q->finished();
}

void inspectRequest_finished()
Expand Down
4 changes: 1 addition & 3 deletions src/cpp/proxy/requestsession.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ class RequestSession : public QObject
// methods. the object remains in an active state though, and so you
// should still wait for finished()
Signal errorResponding;

signals:
void finished();
Signal finished;

private:
class Private;
Expand Down
Loading