From a4bf3113e62ecfb74ab2c89f1cdfc7375af1c59e Mon Sep 17 00:00:00 2001 From: Shulhan Date: Tue, 3 Feb 2026 20:32:57 +0700 Subject: all: fix data race in tests and [httpServer.ExecuteTail] In the test for AwwanLocal, use buffer with lock, so each write and read is safe. In the httpServer, the test found data race during ExecuteTail when accessing [ExecResponse.EndAt]. We fix it by locking the resource during call to end() and when accessing the EndAt field. --- http_server.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'http_server.go') diff --git a/http_server.go b/http_server.go index 2a7f534..f2a35b4 100644 --- a/http_server.go +++ b/http_server.go @@ -853,11 +853,14 @@ func (httpd *httpServer) ExecuteTail(sseconn *libhttp.SSEConn) { evid int64 ) + execRes.mtxOutput.Lock() if len(execRes.EndAt) != 0 { // The execution has been completed. _ = sseconn.WriteEvent(`end`, execRes.EndAt, nil) + execRes.mtxOutput.Unlock() goto out } + execRes.mtxOutput.Unlock() // And wait for the rest... -- cgit v1.3