Skip to content

Commit

Permalink
clarify rtimer init values, and init from domainmap thread (#48030)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkarneges authored Jun 27, 2024
1 parent 311780f commit 0b8890f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/core/zwebsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class ZWebSocket::Private : public QObject
int outContentType;
bool multi;
Connection expireTimerConnection;
Connection keppAliveTimerConnection;
Connection keepAliveTimerConnection;

Private(ZWebSocket *_q) :
QObject(_q),
Expand Down Expand Up @@ -131,7 +131,7 @@ class ZWebSocket::Private : public QObject
expireTimer->setSingleShot(true);

keepAliveTimer = new RTimer;
keppAliveTimerConnection = keepAliveTimer->timeout.connect(boost::bind(&Private::keepAlive_timeout, this));
keepAliveTimerConnection = keepAliveTimer->timeout.connect(boost::bind(&Private::keepAlive_timeout, this));
}

~Private()
Expand All @@ -157,7 +157,7 @@ class ZWebSocket::Private : public QObject

if(keepAliveTimer)
{
keppAliveTimerConnection.disconnect();
keepAliveTimerConnection.disconnect();
keepAliveTimer->setParent(0);
keepAliveTimer->deleteLater();
keepAliveTimer = 0;
Expand Down
10 changes: 8 additions & 2 deletions src/handler/handlerengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@
#define INSPECT_WORKERS_MAX 10
#define ACCEPT_WORKERS_MAX 10

// each session can have a bunch of timers:
// 2 per incoming zhttprequest
// 2 per outgoing zhttprequest
// 2 per httpsession
#define TIMERS_PER_SESSION 10

using namespace VariantUtil;

static QList<PublishItem> parseItems(const QVariantList &vitems, bool *ok = 0, QString *errorMessage = 0)
Expand Down Expand Up @@ -1327,8 +1333,8 @@ class HandlerEngine::Private : public QObject
{
config = _config;

// up to 10 timers per connection, plus an extra 100 for misc
RTimer::init((config.connectionsMax * 10) + 100);
// enough timers for sessions, plus an extra 100 for misc
RTimer::init((config.connectionsMax * TIMERS_PER_SESSION) + 100);

publishLimiter->setRate(config.messageRate);
publishLimiter->setHwm(config.messageHwm);
Expand Down
6 changes: 6 additions & 0 deletions src/proxy/domainmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include "rtimer.h"
#include "routesfile.h"

#define WORKER_THREAD_TIMERS 1

class DomainMap::Worker : public QObject
{
Q_OBJECT
Expand Down Expand Up @@ -735,13 +737,17 @@ class DomainMap::Thread : public QThread

virtual void run()
{
RTimer::init(WORKER_THREAD_TIMERS);

worker = new Worker;
worker->fileName = fileName;
Connection startedConnection = worker->started.connect(boost::bind(&Thread::worker_started, this));
QMetaObject::invokeMethod(worker, "start", Qt::QueuedConnection);
exec();
startedConnection.disconnect();
delete worker;

RTimer::deinit();
}

public:
Expand Down
15 changes: 13 additions & 2 deletions src/proxy/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@
#define DEFAULT_HWM 1000
#define ZROUTES_MAX 100

// each session can have a bunch of timers:
// 2 per incoming zhttprequest/zwebsocket
// 2 per outgoing zhttprequest/zwebsocket
// 1 per wsproxysession
// 2 per websocketoverhttp
// 1 per inspect/accept request
#define TIMERS_PER_SESSION 10

// each zroute has a zhttpmanager, which has up to 8 timers
#define TIMERS_PER_ZROUTE 10

class Engine::Private : public QObject
{
Q_OBJECT
Expand Down Expand Up @@ -207,8 +218,8 @@ class Engine::Private : public QObject
{
config = _config;

// up to 10 timers per session, up to 10 per zroute, plus an extra 100 for misc
RTimer::init((config.sessionsMax * 10) + (ZROUTES_MAX * 10) + 100);
// enough timers for sessions and zroutes, plus an extra 100 for misc
RTimer::init((config.sessionsMax * TIMERS_PER_SESSION) + (ZROUTES_MAX * TIMERS_PER_ZROUTE) + 100);

logConfig.fromAddress = config.logFrom;
logConfig.userAgent = config.logUserAgent;
Expand Down

0 comments on commit 0b8890f

Please sign in to comment.