Skip to content

Commit

Permalink
add generation field to process
Browse files Browse the repository at this point in the history
  • Loading branch information
CamJN committed Sep 9, 2024
1 parent 3d86be0 commit 20df215
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/agent/Core/ApplicationPool/Group/InternalUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ Group::createNullProcessObject() {
LockGuard l(context->memoryManagementSyncher);
Process *process = context->processObjectPool.malloc();
Guard guard(context, process);
process = new (process) Process(&info, args);
process = new (process) Process(&info, info.group->restartsInitiated, args);
process->shutdownNotRequired();
guard.clear();
return ProcessPtr(process, false);
Expand Down Expand Up @@ -215,7 +215,7 @@ Group::createProcessObject(const SpawningKit::Spawner &spawner,
LockGuard l(context->memoryManagementSyncher);
Process *process = context->processObjectPool.malloc();
Guard guard(context, process);
process = new (process) Process(&info, spawnResult, args);
process = new (process) Process(&info, info.group->restartsInitiated, spawnResult, args);
guard.clear();
return ProcessPtr(process, false);
}
Expand Down
11 changes: 8 additions & 3 deletions src/agent/Core/ApplicationPool/Process.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,10 @@ class Process {

/** Last time when a session was opened for this Process. */
unsigned long long lastUsed;
/** Which gereration of app processes this one belongs to,
inherited from the app group, incremented when a restart
is initiated*/
const unsigned int generation;
/** Number of sessions currently open.
* @invariant session >= 0
*/
Expand Down Expand Up @@ -446,8 +450,7 @@ class Process {
/** Collected by Pool::collectAnalytics(). */
ProcessMetrics metrics;


Process(const BasicGroupInfo *groupInfo, const Json::Value &args)
Process(const BasicGroupInfo *groupInfo, const unsigned int gen, const Json::Value &args)
: info(this, groupInfo, args),
socketsAcceptingHttpRequestsCount(0),
spawnerCreationTime(getJsonUint64Field(args, "spawner_creation_time")),
Expand All @@ -458,6 +461,7 @@ class Process {
refcount(1),
index(-1),
lastUsed(spawnEndTime),
generation(gen),
sessions(0),
processed(0),
lifeStatus(ALIVE),
Expand All @@ -471,7 +475,7 @@ class Process {
indexSocketsAcceptingHttpRequests();
}

Process(const BasicGroupInfo *groupInfo, const SpawningKit::Result &skResult,
Process(const BasicGroupInfo *groupInfo, const unsigned int gen, const SpawningKit::Result &skResult,
const Json::Value &args)
: info(this, groupInfo, skResult),
socketsAcceptingHttpRequestsCount(0),
Expand All @@ -483,6 +487,7 @@ class Process {
refcount(1),
index(-1),
lastUsed(spawnEndTime),
generation(gen),
sessions(0),
processed(0),
lifeStatus(ALIVE),
Expand Down

0 comments on commit 20df215

Please sign in to comment.