Skip to content

Commit 071dba7

Browse files
committed
Add mutex around updating client in the CommandService
1 parent c895042 commit 071dba7

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

internal/collector/nginxplusreceiver/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ metrics:
184184
attributes:
185185
- nginx.cache.outcome
186186
- nginx.cache.name
187-
nginx.cache.responses:
187+
nginx.cache.response.count:
188188
enabled: true
189189
description: The total number of responses read from the cache or proxied server.
190190
sum:

internal/command/command_plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func (cp *CommandPlugin) processConnectionReset(ctx context.Context, msg *bus.Me
184184
}
185185
cp.conn = newConnection
186186
cp.commandService.UpdateClient(cp.conn.CommandServiceClient())
187-
slog.DebugContext(ctx, "Command plugin: client reset successfully")
187+
slog.DebugContext(ctx, "Command service client reset successfully")
188188
}
189189
}
190190

internal/command/command_service.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type (
4747
subscribeClientMutex sync.Mutex
4848
configApplyRequestQueueMutex sync.Mutex
4949
resourceMutex sync.Mutex
50+
commandMutex sync.Mutex
5051
}
5152
)
5253

@@ -253,6 +254,8 @@ func (cs *CommandService) CreateConnection(
253254
}
254255

255256
func (cs *CommandService) UpdateClient(client mpi.CommandServiceClient) {
257+
cs.commandMutex.Lock()
258+
defer cs.commandMutex.Unlock()
256259
cs.commandServiceClient = client
257260
}
258261

0 commit comments

Comments
 (0)