From bc33f9b165d15254a434b3175f465dd2e4e7f70f Mon Sep 17 00:00:00 2001 From: Helin Wang Date: Wed, 17 May 2017 20:19:14 -0400 Subject: [PATCH] fix bug lock is released too soon --- paddle/go/pserver/service.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paddle/go/pserver/service.go b/paddle/go/pserver/service.go index 0d10da988..22f6cdf40 100644 --- a/paddle/go/pserver/service.go +++ b/paddle/go/pserver/service.go @@ -110,7 +110,7 @@ func (s *Service) SendGrads(grads []Gradient, dummy *int) error { } s.mu.Lock() - s.mu.Unlock() + defer s.mu.Unlock() for _, g := range grads { if _, ok := s.paramMap[g.Name]; !ok { @@ -134,7 +134,7 @@ func (s *Service) SendGrads(grads []Gradient, dummy *int) error { func (s *Service) GetParams(names []string, parameters *[]Parameter) error { <-s.initialized s.mu.Lock() - s.mu.Unlock() + defer s.mu.Unlock() for _, n := range names { if _, ok := s.paramMap[n]; !ok { -- GitLab