diff --git a/Makefile b/Makefile index b8fc282..ba1d2f0 100644 --- a/Makefile +++ b/Makefile @@ -206,6 +206,7 @@ ifeq ($(words $(MAKECMDGOALS)),1) @$(MAKE) service ${.DEFAULT_GOAL} --no-print-directory endif +bin-docker: BUILD_ARGS = -tags=mutex_debug bin-docker: bin build/linux-amd64/nebula build/linux-amd64/nebula-cert smoke-docker: bin-docker diff --git a/lighthouse.go b/lighthouse.go index daf122c..bdabbd7 100644 --- a/lighthouse.go +++ b/lighthouse.go @@ -468,6 +468,7 @@ func (lh *LightHouse) QueryServer(ip iputil.VpnIp) { return } + chanDebugSend("lighthouse-query-chan") lh.queryChan <- ip } @@ -750,6 +751,8 @@ func (lh *LightHouse) startQueryWorker() { nb := make([]byte, 12, 12) out := make([]byte, mtu) + chanDebugRecv("lighthouse-query-chan") + for { select { case <-lh.ctx.Done(): diff --git a/mutex_debug.go b/mutex_debug.go index 2fc6eb7..ee065ea 100644 --- a/mutex_debug.go +++ b/mutex_debug.go @@ -135,6 +135,19 @@ func checkMutex(state map[mutexKey]mutexValue, add mutexKey) { } } +func chanDebugRecv(key mutexKey) { + m := threadLocal.Get().(map[mutexKey]mutexValue) + checkMutex(m, key) + v := mutexValue{} + _, v.file, v.line, _ = runtime.Caller(1) + m[key] = v +} + +func chanDebugSend(key mutexKey) { + m := threadLocal.Get().(map[mutexKey]mutexValue) + checkMutex(m, key) +} + func (s *syncRWMutex) Lock() { m := threadLocal.Get().(map[mutexKey]mutexValue) checkMutex(m, s.mutexKey) diff --git a/mutex_nodebug.go b/mutex_nodebug.go index 76086ff..87e0c5a 100644 --- a/mutex_nodebug.go +++ b/mutex_nodebug.go @@ -18,3 +18,6 @@ func newSyncRWMutex(mutexKey) syncRWMutex { func newSyncMutex(mutexKey) syncMutex { return sync.Mutex{} } + +func chanDebugRecv(key mutexKey) {} +func chanDebugSend(key mutexKey) {}