Skip to content

Commit

Permalink
Merge pull request micro#224 from dh1tw/rpc-server-subscribe-deadlock
Browse files Browse the repository at this point in the history
fix possible deadlock since code can return without unlocking the Mutex
  • Loading branch information
Asim Aslam committed Jan 2, 2018
2 parents b0b0338 + 0dcea05 commit 45420d8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion server/rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ func (s *rpcServer) Subscribe(sb Subscriber) error {
}

s.Lock()
defer s.Unlock()
_, ok = s.subscribers[sub]
if ok {
return fmt.Errorf("subscriber %v already exists", s)
}
s.subscribers[sub] = nil
s.Unlock()
return nil
}

Expand Down

0 comments on commit 45420d8

Please sign in to comment.