Skip to content

Commit d9733fb

Browse files
committed
Guard Peek call with mutex for thread safety
1 parent 015c759 commit d9733fb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

command.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5454,8 +5454,9 @@ func (cmd *MonitorCmd) readMonitor(rd *proto.Reader, cancel context.CancelFunc)
54545454
for {
54555455
cmd.mu.Lock()
54565456
st := cmd.status
5457+
pk, _ := rd.Peek(1)
54575458
cmd.mu.Unlock()
5458-
if pk, _ := rd.Peek(1); len(pk) != 0 && st == monitorStatusStart {
5459+
if len(pk) != 0 && st == monitorStatusStart {
54595460
cmd.mu.Lock()
54605461
line, err := rd.ReadString()
54615462
cmd.mu.Unlock()

0 commit comments

Comments
 (0)