Class sh::ui::web::WebServerEngineDispatcher::WorkerProcess

class sh::ui::web::WebServerEngineDispatcher::WorkerProcess : public QProcess

A internal Shallot worker process driving one Shallot session.

Public Functions

QByteArray wtoken()

The wtoken (used for association and security).

QUrl rootUrl()

The worker root url.

void request(WebServerEngineRequest *request)

Make a request to the worker.

qint64 workerPid()

Returns the process id of the worker.

qint64 memoryUsage()

Returns the current memory usage of this worker (in bytes).

Returns -1 if this is not supported on the target platform or it failed.

QDateTime lastBrowserHeartbeat()

Returns when a browser was seen connected to this worker last time.

QDateTime lastUserInteraction()

Returns when a user has interacted with this worker last time.

QString clientHost()

Returns the client host this worker is serving.

It’s not guaranteed to have some specific content (maybe an ip address), but is equal for the same host, some one can count how many hosts work for one particular client host.

QString preventCloseMessage()

Returns a reason message why this worker currently should not be closed (or "" if closing is fine).

See also isClosingInappropriate().

Note: This is reported asynchronously. You must not rely on its precise information, but solely use it for monitoring.

bool isClosingFine()

Returns if it is fine to stop this worker (or if there is a good reason to not do).

See also preventCloseMessage().

Note: This is reported asynchronously. You must not rely on its precise information, but solely use it for monitoring.

Private Functions

WorkerProcess(WebServerEngineDispatcher *dispatcher, QByteArray wtoken, QString clientHost, QStringList acceptedLanguages)
bool waitOnline()

Waits until the worker is online and ready for requests (or dead).

void initialize(QString rooturl, qint64 pid)

Initializes the worker instance (which exists on the dispatcher side!) by setting some final data.

void gotBrowserHeartbeat()

Refreshes the browser heartbeat timestamp.

See lastBrowserHeartbeat().

void gotUserInteraction(int value)

Refreshes the user interaction timestamp.

See lastUserInteraction().

void setPreventCloseMessage(QString message)

Sets the preventCloseMessage (empty: closeable).

Private Members

WebServerEngineDispatcher *_dispatcher
QByteArray _wtoken
QUrl _rooturl
QMutex _mutex
QWaitCondition _cnd_inited
qint64 _pid = -1
QDateTime _lastBrowserHeartbeat
QDateTime _lastUserInteraction
QString _clientHost
QString _preventCloseMessage
QRegularExpression _reProcStatus

Friends

friend class WebServerEngineDispatcher