lib/sync: Log everything...

This commit is contained in:
Audrius Butkevicius
2016-11-03 21:33:33 +00:00
parent e408f1061a
commit 3418497f3d
3 changed files with 99 additions and 43 deletions

View File

@@ -12,8 +12,8 @@ import (
"time"
)
type Holder interface {
Holder() (string, int)
type Holdable interface {
Holders() string
}
func newDeadlockDetector(timeout time.Duration) *deadlockDetector {
@@ -49,9 +49,8 @@ func (d *deadlockDetector) Watch(name string, mut sync.Locker) {
if r := <-ok; !r {
msg := fmt.Sprintf("deadlock detected at %s", name)
for otherName, otherMut := range d.lockers {
if otherHolder, ok := otherMut.(Holder); ok {
holder, goid := otherHolder.Holder()
msg += fmt.Sprintf("\n %s = current holder: %s at routine %d", otherName, holder, goid)
if otherHolder, ok := otherMut.(Holdable); ok {
msg += "\n===" + otherName + "===\n" + otherHolder.Holders()
}
}
panic(msg)