chore: fix potential race
This commit is contained in:
parent
e80ec13c73
commit
ca9c557929
1 changed files with 2 additions and 2 deletions
|
|
@ -56,8 +56,8 @@ func (cp *handler[T]) Add(dev Device[T]) error {
|
|||
|
||||
// Delete deletes device
|
||||
func (cp *handler[T]) Delete(name string) error {
|
||||
cp.mu.RLock()
|
||||
defer cp.mu.RUnlock()
|
||||
cp.mu.Lock()
|
||||
defer cp.mu.Unlock()
|
||||
|
||||
for i, dev := range cp.devices {
|
||||
if name == dev.Config().Name {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue