Browse Source

lib/protocol, rc, utils: Add mutex Unlock before panic (#6556)

Boqin Qin 5 years ago
parent
commit
c63ca4f563
3 changed files with 3 additions and 0 deletions
  1. 1 0
      lib/protocol/protocol.go
  2. 1 0
      lib/rc/rc.go
  3. 1 0
      lib/util/utils.go

+ 1 - 0
lib/protocol/protocol.go

@@ -289,6 +289,7 @@ func (c *rawConnection) Request(ctx context.Context, folder string, name string,
 
 	c.awaitingMut.Lock()
 	if _, ok := c.awaiting[id]; ok {
+		c.awaitingMut.Unlock()
 		panic("id taken")
 	}
 	rc := make(chan asyncResult, 1)

+ 1 - 0
lib/rc/rc.go

@@ -547,6 +547,7 @@ func (p *Process) eventLoop() {
 				}
 				device := p.id.String()
 				if device == "" {
+					p.eventMut.Unlock()
 					panic("race, or startup not complete")
 				}
 				m[device] = version

+ 1 - 0
lib/util/utils.go

@@ -251,6 +251,7 @@ func (s *service) Stop() {
 	s.mut.Lock()
 	select {
 	case <-s.ctx.Done():
+		s.mut.Unlock()
 		panic(fmt.Sprintf("Stop called more than once on %v", s))
 	default:
 		s.cancel()