]> Cypherpunks repositories - gostls13.git/commitdiff
acid bug fix.
authorRuss Cox <rsc@golang.org>
Fri, 9 Oct 2009 23:45:20 +0000 (16:45 -0700)
committerRuss Cox <rsc@golang.org>
Fri, 9 Oct 2009 23:45:20 +0000 (16:45 -0700)
lock printf output to avoid interlacing debug prints.

R=r
DELTA=10  (7 added, 0 deleted, 3 changed)
OCL=35539
CL=35561

src/pkg/runtime/print.c

index c9929cd4543e2b29b4a4c179a44b2698c3fd1149..fb2881be55a49a3f3e02530a7333fbdafc102dee 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "runtime.h"
 
+static Lock debuglock;
 
 void
 dump(byte *p, int32 n)
@@ -36,6 +37,8 @@ printf(int8 *s, ...)
        int8 *p, *lp;
        byte *arg, *narg;
 
+       lock(&debuglock);
+
        lp = p = s;
        arg = (byte*)(&s+1);
        for(; *p; p++) {
@@ -96,6 +99,8 @@ printf(int8 *s, ...)
        }
        if(p > lp)
                write(1, lp, p-lp);
+
+       unlock(&debuglock);
 }