runtime: Provide protection for shared data
The k.reqHandlers should be protected by locks when used
Fixes
@@ -2044,10 +2044,20 @@ func (k *kataAgent) sendReq(spanCtx context.Context, request interface{}) (inter
}
msgName := proto.MessageName(request.(proto.Message))
+
+ k.Lock()
+
+ if k.reqHandlers == nil {
+ return nil, errors.New("Client has already disconnected")
+ }
+
handler := k.reqHandlers[msgName]
if msgName == "" || handler == nil {
return nil, errors.New("Invalid request type")
}
+
+ k.Unlock()
+
message := request.(proto.Message)
ctx, cancel := k.getReqContext(spanCtx, msgName)
if cancel != nil {
