mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 04:04:45 +00:00
runtime: Provide protection for shared data
The k.reqHandlers should be protected by locks when used Fixes #3440 Signed-off-by: liangxianlong <liang.xianlong@zte.com.cn>
This commit is contained in:
parent
ef835b5948
commit
878ab93c15
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user