diff options
author | Dean Deng <deandeng@google.com> | 2021-01-15 14:38:44 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-01-15 14:40:26 -0800 |
commit | 9db126eb65ada4b2233ccb85a0e9c402b7efc5de (patch) | |
tree | 5db016c8435c28dd2d56a93b662b6b5b26ac47c3 /pkg/refsvfs2 | |
parent | f03144d886791afcdd37962388e9a6294a08c49f (diff) |
Combine reference count logs into one message.
Otherwise, races can occur between concurrent logs.
PiperOrigin-RevId: 352086914
Diffstat (limited to 'pkg/refsvfs2')
-rw-r--r-- | pkg/refsvfs2/refs_map.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/pkg/refsvfs2/refs_map.go b/pkg/refsvfs2/refs_map.go index 9fbc5466f..0472eca3f 100644 --- a/pkg/refsvfs2/refs_map.go +++ b/pkg/refsvfs2/refs_map.go @@ -109,8 +109,7 @@ func LogDecRef(obj CheckedObject, refs int64) { // obj.LogRefs() should be checked before calling logEvent, in order to avoid // calling any text processing needed to evaluate msg. func logEvent(obj CheckedObject, msg string) { - log.Infof("[%s %p] %s:", obj.RefType(), obj, msg) - log.Infof(refs_vfs1.FormatStack(refs_vfs1.RecordStack())) + log.Infof("[%s %p] %s:\n%s", obj.RefType(), obj, msg, refs_vfs1.FormatStack(refs_vfs1.RecordStack())) } // DoLeakCheck iterates through the live object map and logs a message for each @@ -122,10 +121,11 @@ func DoLeakCheck() { defer liveObjectsMu.Unlock() leaked := len(liveObjects) if leaked > 0 { - log.Warningf("Leak checking detected %d leaked objects:", leaked) + msg := fmt.Sprintf("Leak checking detected %d leaked objects:\n", leaked) for obj := range liveObjects { - log.Warningf(obj.LeakMessage()) + msg += obj.LeakMessage() + "\n" } + log.Warningf(msg) } } } |