@@ -19,14 +19,16 @@ import (
19
19
20
20
type DeviceAgentServer struct {
21
21
pb.UnimplementedDeviceAgentServer
22
- AgentStatus * pb.AgentStatus
23
22
lock sync.RWMutex
24
23
statusChannels map [uuid.UUID ]chan * pb.AgentStatus
25
24
Config * config.Config
26
25
notifier notify.Notifier
27
26
rc runtimeconfig.RuntimeConfig
28
27
log * logrus.Entry
29
28
sendEvent func (state.EventWithSpan )
29
+
30
+ AgentStatus * pb.AgentStatus
31
+ agentStatusLock sync.RWMutex
30
32
}
31
33
32
34
func (das * DeviceAgentServer ) Login (ctx context.Context , request * pb.LoginRequest ) (* pb.LoginResponse , error ) {
@@ -45,7 +47,9 @@ func (das *DeviceAgentServer) Status(request *pb.AgentStatusRequest, statusServe
45
47
das .log .Debug ("grpc: client connection established to device helper" )
46
48
47
49
agentStatusChan := make (chan * pb.AgentStatus , 8 )
50
+ das .agentStatusLock .RLock ()
48
51
agentStatusChan <- das .AgentStatus
52
+ das .agentStatusLock .RUnlock ()
49
53
50
54
das .lock .Lock ()
51
55
das .statusChannels [id ] = agentStatusChan
@@ -81,7 +85,9 @@ func (das *DeviceAgentServer) ConfigureJITA(context.Context, *pb.ConfigureJITARe
81
85
}
82
86
83
87
func (das * DeviceAgentServer ) UpdateAgentStatus (status * pb.AgentStatus ) {
88
+ das .agentStatusLock .Lock ()
84
89
das .AgentStatus = status
90
+ das .agentStatusLock .Unlock ()
85
91
86
92
das .lock .RLock ()
87
93
for _ , c := range das .statusChannels {
0 commit comments