fix another race

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
This commit is contained in:
Mohammed Al Sahaf 2025-08-03 04:30:47 +03:00
parent 7ac7ca3ff4
commit f7d16df78e
No known key found for this signature in database

View File

@ -95,10 +95,15 @@ func (ms *mockServer) handleConnection(conn net.Conn) {
scanner := bufio.NewScanner(conn) scanner := bufio.NewScanner(conn)
for scanner.Scan() { for scanner.Scan() {
line := scanner.Text() select {
ms.mu.Lock() case <-ms.ctx.Done():
ms.messages = append(ms.messages, line) return
ms.mu.Unlock() default:
line := scanner.Text()
ms.mu.Lock()
ms.messages = append(ms.messages, line)
ms.mu.Unlock()
}
} }
} }