Skip to content

Commit 838558d

Browse files
committed
inferserver extend security lock scope
1 parent 576a677 commit 838558d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

inference/synapse/local_infer.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ func (s *Synapse) inferByInputContent(modelInfoHash, inputInfoHash string, input
121121
log.Debug("Infer Succeed via Cache", "result", v.([]byte))
122122
return v.([]byte), nil
123123
}
124-
124+
s.mutex.Lock()
125+
defer s.mutex.Unlock()
125126
// lazy initialization of model cache
126127
if _, ok := s.caches[s.config.DeviceId]; !ok {
127128
memoryUsage := s.config.MaxMemoryUsage
@@ -143,8 +144,6 @@ func (s *Synapse) inferByInputContent(modelInfoHash, inputInfoHash string, input
143144

144145
//v, _ := s.modelLock.LoadOrStore(modelHash, sync.Mutex{})
145146
//mutex := v.(sync.Mutex)
146-
s.mutex.Lock()
147-
defer s.mutex.Unlock()
148147

149148
model_tmp, has_model := s.caches[s.config.DeviceId].Get(modelHash)
150149
if !has_model {

0 commit comments

Comments
 (0)