File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change 99 "os"
1010 "os/exec"
1111 "regexp"
12+ "sync"
1213 "time"
1314
1415 "golang.org/x/sync/errgroup"
@@ -151,14 +152,24 @@ func (c conn) waitWithTimeout() error {
151152}
152153
153154type tailBuffer struct {
155+ mu sync.Mutex
156+
154157 limit int
155- bytes.Buffer
158+ buff bytes.Buffer
156159}
157160
158161func (b * tailBuffer ) Write (p []byte ) (n int , err error ) {
159- if len (p )+ b .Buffer .Len () > b .limit {
160- b .Reset ()
162+ b .mu .Lock ()
163+ defer b .mu .Unlock ()
164+ if len (p )+ b .buff .Len () > b .limit {
165+ b .buff .Reset ()
161166 }
162- n , err = b .Buffer .Write (p )
167+ n , err = b .buff .Write (p )
163168 return
164169}
170+
171+ func (b * tailBuffer ) String () string {
172+ b .mu .Lock ()
173+ defer b .mu .Unlock ()
174+ return b .buff .String ()
175+ }
You can’t perform that action at this time.
0 commit comments