From 4fef7114a3812b8c690d3a25f8ba16ed83389a29 Mon Sep 17 00:00:00 2001 From: Ben Castricum Date: Wed, 26 Jan 2022 11:05:02 +0100 Subject: [PATCH] Revert defer unlock in StayRTR AddVRPs vrplock needs to be unlocked before AddVRPsDiff() because AddVRPsDiff needs a full lock. I added some debug logging found this deadlock INFO[0000] new cache file: Updating sha256 hash -> da753c7804d6f386bf303fed6931853eaaca0771ba160ef7fdbebb17e899d78b INFO[0001] New update (306189 uniques, 306189 total prefixes). INFO[0001] RLocking vrplock in AddVRPs INFO[0002] RLocking vrplock in AddVRPsDiff INFO[0002] RUnlocked vrplock in AddVRPsDiff INFO[0002] Locking vrplock in AddVRPsDiff ... --- lib/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server.go b/lib/server.go index a38f43a..8a925ca 100644 --- a/lib/server.go +++ b/lib/server.go @@ -346,7 +346,6 @@ func (s *Server) SetSerial(serial uint32) { func (s *Server) AddVRPs(vrps []VRP) { s.vrplock.RLock() - defer s.vrplock.RUnlock() vrpCurrent := s.vrpCurrent @@ -357,6 +356,7 @@ func (s *Server) AddVRPs(vrps []VRP) { s.log.Debugf("Computed diff: added (%d), removed (%d), unchanged (%d)", len(added), len(removed), len(unchanged)) } curDiff := append(added, removed...) + s.vrplock.RUnlock() s.AddVRPsDiff(curDiff) }