Files
Zakk 7c482856c8 fix(kernel): races and leaks around the core process and the observatory
Running() reads the process under the manager's lock; the early-exit
flag is atomic; a second Close no longer waits on the reaped process; an
empty log chunk no longer panics. The observatory producer rejects tags
it cannot map instead of attributing them to the first node, paces every
path so an unknown tag cannot spin it, closes an unavailable connection
before dropping it and cancels each dial context at once. Balancer
outbounds get their serverInfoMap entry on success, not only on failure.
The resolv hijacker is serialised between the start path and the
connectivity monitor.
2026-09-19 22:04:03 +10:00

27 lines
636 B
Go

package v2ray
import "testing"
func TestProcessCloseMarksExpectedStopBeforeCancel(t *testing.T) {
process := &Process{template: &Template{}}
process.procCancel = func() {
if !process.expectedStop.Load() {
t.Fatal("expected stop must be recorded before canceling the core")
}
}
if err := process.Close(); err != nil {
t.Fatalf("Close() error = %v", err)
}
if !process.expectedStop.Load() {
t.Fatal("Close() did not record the expected stop")
}
}
func TestLogInfoWriterEmptyWrite(t *testing.T) {
n, err := (logInfoWriter{}).Write(nil)
if n != 0 || err != nil {
t.Fatalf("empty write: n=%d, err=%v", n, err)
}
}