diff options
| author | Shulhan <ms@kilabit.info> | 2026-02-03 20:32:57 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2026-02-03 20:32:57 +0700 |
| commit | a4bf3113e62ecfb74ab2c89f1cdfc7375af1c59e (patch) | |
| tree | a8eb21efca4e3ac70cd0bba1f18da28b479d6d59 /http_server.go | |
| parent | c21d2b336176b740539f655f600caa353d7150f4 (diff) | |
| download | awwan-a4bf3113e62ecfb74ab2c89f1cdfc7375af1c59e.tar.xz | |
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.
Diffstat (limited to 'http_server.go')
| -rw-r--r-- | http_server.go | 3 |
1 files changed, 3 insertions, 0 deletions
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... |
