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 /exec_response.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 'exec_response.go')
| -rw-r--r-- | exec_response.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/exec_response.go b/exec_response.go index a5cb1ff..92774cf 100644 --- a/exec_response.go +++ b/exec_response.go @@ -89,6 +89,9 @@ func (execRes *ExecResponse) Write(out []byte) (n int, err error) { // end mark the execution completed, possibly with error. func (execRes *ExecResponse) end(execErr error) { + execRes.mtxOutput.Lock() + defer execRes.mtxOutput.Unlock() + var ev sseclient.Event if execErr != nil { |
