mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-10 05:10:58 +00:00
fix(mtproto): synchronize child-process lifecycle (#6141)
* fix(mtproto): synchronize child-process state Use lifecycle snapshots around the mtg command, completion signal, and exit error so Wait cannot race status and shutdown reads. * test(mtproto): cover concurrent process exit * test(mtproto): cover lifecycle field synchronization --------- Co-authored-by: PathGao <gaoyanbo@gaoyanbodeMacBook-Air.local>
This commit is contained in:
@@ -21,6 +21,16 @@ func TestMain(m *testing.M) {
|
||||
fmt.Fprintf(f, "%d\n", os.Getpid())
|
||||
f.Close()
|
||||
}
|
||||
if exitFile := os.Getenv("MTG_FAKE_EXIT_FILE"); exitFile != "" {
|
||||
for {
|
||||
if _, err := os.Stat(exitFile); err == nil {
|
||||
os.Exit(1)
|
||||
} else if !os.IsNotExist(err) {
|
||||
os.Exit(2)
|
||||
}
|
||||
time.Sleep(time.Millisecond)
|
||||
}
|
||||
}
|
||||
select {}
|
||||
}
|
||||
os.Exit(m.Run())
|
||||
|
||||
Reference in New Issue
Block a user