From 6ab1b52d6d9c8c4885dda8c8932626c5ed4a3902 Mon Sep 17 00:00:00 2001 From: "Hongli Lai (Phusion)" Date: Thu, 3 Oct 2024 16:55:09 +0200 Subject: [PATCH] Use spawnStartTime instead of spawnerCreationTime --- .../Group/ProcessListManagement.cpp | 10 ++++----- src/agent/Core/ApplicationPool/Process.h | 22 ++++++++++--------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/agent/Core/ApplicationPool/Group/ProcessListManagement.cpp b/src/agent/Core/ApplicationPool/Group/ProcessListManagement.cpp index 5d5e304bfa..8020020417 100644 --- a/src/agent/Core/ApplicationPool/Group/ProcessListManagement.cpp +++ b/src/agent/Core/ApplicationPool/Group/ProcessListManagement.cpp @@ -68,8 +68,8 @@ Group::findBestProcessPreferringStickySessionId(unsigned int id) const { return process; } else if (bestProcess == nullptr || process->generation > bestProcess->generation || - (process->generation == bestProcess->generation && process->spawnerCreationTime < bestProcess->spawnerCreationTime) || - (process->generation == bestProcess->generation && process->spawnerCreationTime == bestProcess->spawnerCreationTime && process->busyness() < bestProcess->busyness()) + (process->generation == bestProcess->generation && process->spawnStartTime < bestProcess->spawnStartTime) || + (process->generation == bestProcess->generation && process->spawnStartTime == bestProcess->spawnStartTime && process->busyness() < bestProcess->busyness()) ) { bestProcess = process; } @@ -91,8 +91,8 @@ Group::findBestProcess(const ProcessList &processes) const { if (bestProcess == nullptr || process->generation > bestProcess->generation || - (process->generation == bestProcess->generation && process->spawnerCreationTime < bestProcess->spawnerCreationTime) || - (process->generation == bestProcess->generation && process->spawnerCreationTime == bestProcess->spawnerCreationTime && process->busyness() < bestProcess->busyness()) + (process->generation == bestProcess->generation && process->spawnStartTime < bestProcess->spawnStartTime) || + (process->generation == bestProcess->generation && process->spawnStartTime == bestProcess->spawnStartTime && process->busyness() < bestProcess->busyness()) ) { bestProcess = process; } @@ -119,7 +119,7 @@ Group::findBestEnabledProcess() const { for (unsigned int i = 0; i < size; i++) { Process *process = enabledProcesses.at(i).get(); unsigned int gen = process->generation; - unsigned long long startTime = process->spawnerCreationTime; + unsigned long long startTime = process->spawnStartTime; int busyness = enabledProcessBusynessLevels[i]; if (bestProcess == nullptr || gen > bestProcess->generation || diff --git a/src/agent/Core/ApplicationPool/Process.h b/src/agent/Core/ApplicationPool/Process.h index 0685e367a0..7275402d6d 100644 --- a/src/agent/Core/ApplicationPool/Process.h +++ b/src/agent/Core/ApplicationPool/Process.h @@ -99,13 +99,9 @@ typedef boost::container::vector ProcessList; */ class Process { public: - static const unsigned int MAX_SOCKETS_ACCEPTING_HTTP_REQUESTS = 3; + friend class Group; - /** - * Time at which the Spawner that created this process was created. - * Microseconds resolution. - */ - unsigned long long spawnerCreationTime; + static const unsigned int MAX_SOCKETS_ACCEPTING_HTTP_REQUESTS = 3; private: /************************************************************* @@ -146,6 +142,12 @@ class Process { */ StaticString codeRevision; + /** + * Time at which the Spawner that created this process was created. + * Microseconds resolution. + */ + unsigned long long spawnerCreationTime; + /** Time at which we started spawning this process. Microseconds resolution. */ unsigned long long spawnStartTime; @@ -450,9 +452,9 @@ class Process { ProcessMetrics metrics; Process(const BasicGroupInfo *groupInfo, const unsigned int gen, const Json::Value &args) - : spawnerCreationTime(getJsonUint64Field(args, "spawner_creation_time")), - info(this, groupInfo, args), + : info(this, groupInfo, args), socketsAcceptingHttpRequestsCount(0), + spawnerCreationTime(getJsonUint64Field(args, "spawner_creation_time")), spawnStartTime(getJsonUint64Field(args, "spawn_start_time")), spawnEndTime(SystemTime::getUsec()), type(args["type"] == "dummy" ? SpawningKit::Result::DUMMY : SpawningKit::Result::UNKNOWN), @@ -476,9 +478,9 @@ class Process { Process(const BasicGroupInfo *groupInfo, const unsigned int gen, const SpawningKit::Result &skResult, const Json::Value &args) - : spawnerCreationTime(getJsonUint64Field(args, "spawner_creation_time")), - info(this, groupInfo, skResult), + : info(this, groupInfo, skResult), socketsAcceptingHttpRequestsCount(0), + spawnerCreationTime(getJsonUint64Field(args, "spawner_creation_time")), spawnStartTime(skResult.spawnStartTime), spawnEndTime(skResult.spawnEndTime), type(skResult.type),