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

boostificaiton fixes #47894

Merged
merged 7 commits into from
Jan 27, 2024
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
4 changes: 2 additions & 2 deletions src/cpp/handler/handlerengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ class AcceptWorker : public Deferred
rp.route = route.toUtf8();
rp.retrySeq = stats->lastRetrySeq();

emit retryPacketReady(rp);
retryPacketReady(rp);

setFinished(true);
return;
Expand Down Expand Up @@ -1119,7 +1119,7 @@ class AcceptWorker : public Deferred

// engine should directly connect to this and register the holds
// immediately, to avoid a race with the lastId check
emit sessionsReady();
sessionsReady();

setFinished(true);
}
Expand Down
7 changes: 3 additions & 4 deletions src/cpp/processquit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class SafeSocketNotifier : public QObject
QObject(parent)
{
sn = new QSocketNotifier(socket, type, this);
connect(sn, SIGNAL(activated(int)), SLOT(doActivated()));
connect(sn, &QSocketNotifier::activated, this, &SafeSocketNotifier::doActivated);
}

~SafeSocketNotifier()
Expand All @@ -82,10 +82,9 @@ public slots:
private:
QSocketNotifier *sn;

private slots:
void doActivated()
void doActivated(int sock)
{
activated(sn->socket());
activated(sock);
}
};

Expand Down
56 changes: 33 additions & 23 deletions src/cpp/proxy/sockjsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include "zwebsocket.h"
#include "sockjssession.h"

using std::map;

#define MAX_REQUEST_BODY 100000

const char *iframeHtmlTemplate =
Expand Down Expand Up @@ -68,6 +70,12 @@ static QByteArray serializeJsonString(const QString &s)
return tmp.mid(1, tmp.length() - 2);
}

struct ZhttpReqConnections{
Connection readyReadConnection;
Connection bytesWrittenConnection;
Connection errorConnection;
};

class SockJsManager::Private : public QObject
{
Q_OBJECT
Expand Down Expand Up @@ -110,7 +118,11 @@ class SockJsManager::Private : public QObject

~Session()
{
delete req;
if(req)
{
owner->reqConnectionMap.erase(req);
delete req;
}
delete sock;

if(timer)
Expand All @@ -133,9 +145,7 @@ class SockJsManager::Private : public QObject
QByteArray iframeHtml;
QByteArray iframeHtmlEtag;
QSet<ZhttpRequest*> discardedRequests;
Connection readyReadConnection;
Connection bytesWrittenConnection;
Connection errorConnection;
map<ZhttpRequest*, ZhttpReqConnections> reqConnectionMap;

Private(SockJsManager *_q, const QString &sockJsUrl) :
QObject(_q),
Expand Down Expand Up @@ -241,9 +251,11 @@ class SockJsManager::Private : public QObject

s->route = route;

readyReadConnection = req->readyRead.connect(boost::bind(&Private::req_readyRead, this));
bytesWrittenConnection = req->bytesWritten.connect(boost::bind(&Private::req_bytesWritten, this, boost::placeholders::_1));
errorConnection = req->error.connect(boost::bind(&Private::req_error, this));
reqConnectionMap[req] = {
req->readyRead.connect(boost::bind(&Private::req_readyRead, this, req)),
req->bytesWritten.connect(boost::bind(&Private::req_bytesWritten, this, boost::placeholders::_1, req)),
req->error.connect(boost::bind(&Private::req_error, this, req))
};

sessions += s;
sessionsByRequest.insert(s->req, s);
Expand Down Expand Up @@ -364,9 +376,11 @@ class SockJsManager::Private : public QObject
{
discardedRequests += req;

readyReadConnection = req->readyRead.connect(boost::bind(&Private::req_readyRead, this));
bytesWrittenConnection = req->bytesWritten.connect(boost::bind(&Private::req_bytesWritten, this, boost::placeholders::_1));
errorConnection = req->error.connect(boost::bind(&Private::req_error, this));
reqConnectionMap[req] = {
req->readyRead.connect(boost::bind(&Private::req_readyRead, this, req)),
req->bytesWritten.connect(boost::bind(&Private::req_bytesWritten, this, boost::placeholders::_1, req)),
req->error.connect(boost::bind(&Private::req_error, this, req))
};
}

HttpHeaders headers;
Expand Down Expand Up @@ -484,7 +498,7 @@ class SockJsManager::Private : public QObject
sessionsById.insert(s->sid, s);
s->pending = true;
pendingSessions += s;
emit q->sessionReady();
q->sessionReady();
return;
}
}
Expand All @@ -499,7 +513,7 @@ class SockJsManager::Private : public QObject
{
s->pending = true;
pendingSessions += s;
emit q->sessionReady();
q->sessionReady();
return;
}
else
Expand All @@ -514,7 +528,7 @@ class SockJsManager::Private : public QObject
s->lastPart = lastPart;
s->pending = true;
pendingSessions += s;
emit q->sessionReady();
q->sessionReady();
return;
}

Expand Down Expand Up @@ -575,11 +589,8 @@ class SockJsManager::Private : public QObject
return s->ext;
}

private slots:
void req_readyRead()
void req_readyRead(ZhttpRequest *req)
{
ZhttpRequest *req = (ZhttpRequest *)sender();

// for a request to have been discardable, we must have read the
// entire input already and handed to the session
assert(!discardedRequests.contains(req));
Expand All @@ -590,17 +601,16 @@ private slots:
processRequestInput(s);
}

void req_bytesWritten(int count)
void req_bytesWritten(int count, ZhttpRequest *req)
{
Q_UNUSED(count);

ZhttpRequest *req = (ZhttpRequest *)sender();

if(discardedRequests.contains(req))
{
if(req->isFinished())
{
discardedRequests.remove(req);
reqConnectionMap.erase(req);
delete req;
}

Expand All @@ -617,13 +627,12 @@ private slots:
}
}

void req_error()
void req_error(ZhttpRequest *req)
{
ZhttpRequest *req = (ZhttpRequest *)sender();

if(discardedRequests.contains(req))
{
discardedRequests.remove(req);
reqConnectionMap.erase(req);
delete req;
return;
}
Expand All @@ -637,6 +646,7 @@ private slots:
removeSession(s);
}

private slots:
void sock_closed()
{
ZWebSocket *sock = (ZWebSocket *)sender();
Expand Down
16 changes: 7 additions & 9 deletions src/cpp/proxy/sockjssession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ class SockJsSession::Private : public QObject

requests.insert(req, new RequestItem(req, jsonpCallback, RequestItem::Connect));

bytesWrittenConnection = req->bytesWritten.connect(boost::bind(&Private::req_bytesWritten, this, boost::placeholders::_1));
errorConnection = req->error.connect(boost::bind(&Private::req_error, this));
bytesWrittenConnection = req->bytesWritten.connect(boost::bind(&Private::req_bytesWritten, this, boost::placeholders::_1, req));
errorConnection = req->error.connect(boost::bind(&Private::req_error, this, req));
}
else
{
Expand Down Expand Up @@ -297,8 +297,8 @@ class SockJsSession::Private : public QObject

void handleRequest(ZhttpRequest *_req, const QByteArray &jsonpCallback, const QByteArray &lastPart, const QByteArray &body)
{
bytesWrittenConnection = _req->bytesWritten.connect(boost::bind(&Private::req_bytesWritten, this, boost::placeholders::_1));
errorConnection = _req->error.connect(boost::bind(&Private::req_error, this));
bytesWrittenConnection = _req->bytesWritten.connect(boost::bind(&Private::req_bytesWritten, this, boost::placeholders::_1, req));
errorConnection = _req->error.connect(boost::bind(&Private::req_error, this, req));

if(lastPart == "xhr" || lastPart == "jsonp")
{
Expand Down Expand Up @@ -871,12 +871,10 @@ class SockJsSession::Private : public QObject
return closeValue;
}

private slots:
void req_bytesWritten(int count)
void req_bytesWritten(int count, ZhttpRequest *_req)
{
Q_UNUSED(count);

ZhttpRequest *_req = (ZhttpRequest *)sender();
RequestItem *ri = requests.value(_req);
assert(ri);

Expand Down Expand Up @@ -929,9 +927,8 @@ private slots:
}
}

void req_error()
void req_error(ZhttpRequest *_req)
{
ZhttpRequest *_req = (ZhttpRequest *)sender();
RequestItem *ri = requests.value(_req);
assert(ri);

Expand Down Expand Up @@ -972,6 +969,7 @@ private slots:
}
}

private slots:
void sock_readyRead()
{
if(mode == WebSocketFramed)
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/proxy/websocketoverhttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,6 @@ class WebSocketOverHttp::Private : public QObject
req->endBody();
}

private slots:
void req_readyRead()
{
if(inBuf.size() + req->bytesAvailable() > RESPONSE_BODY_MAX)
Expand Down Expand Up @@ -981,6 +980,7 @@ private slots:
emit q->error();
}

private slots:
void keepAliveTimer_timeout()
{
update();
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/qzmq/src/qzmqsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ class Socket::Private : public QObject
assert(sock != NULL);

sn_read = new QSocketNotifier(get_fd(sock), QSocketNotifier::Read, this);
connect(sn_read, SIGNAL(activated(int)), SLOT(sn_read_activated()));
connect(sn_read, &QSocketNotifier::activated, this, &Private::sn_read_activated);
sn_read->setEnabled(true);

updateTimer = new QTimer(this);
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/zrpcmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class ZrpcManager::Private : public QObject
if(pending.count() >= PENDING_MAX)
serverValve->close();

emit q->requestReady();
q->requestReady();
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/cpp/zrpcrequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class ZrpcRequest::Private : public QObject
q->onError();
}

emit q->finished();
q->finished();
}

private slots:
Expand All @@ -144,7 +144,7 @@ private slots:
condition = ErrorUnavailable;
conditionString = "service-unavailable";
cleanup();
emit q->finished();
q->finished();
return;
}

Expand All @@ -170,7 +170,7 @@ private slots:
condition = ErrorTimeout;
conditionString = "timeout";
cleanup();
emit q->finished();
q->finished();
}
};

Expand Down
Loading