mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #5395] [MERGED] fix(xray): guard process lifecycle fields against concurrent access #5868
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#5868
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/5395
Author: @n0ctal
Created: 6/16/2026
Status: ✅ Merged
Merged: 6/19/2026
Merged by: @MHSanaei
Base:
main← Head:pr-bug2-process-race📝 Commits (1)
fc4f031fix(xray): guard process lifecycle fields against concurrent access📊 Changes
2 files changed (+118 additions, -21 deletions)
View changed files
📝
internal/xray/process.go(+58 -21)➕
internal/xray/process_race_test.go(+60 -0)📄 Description
Summary
Guard the xray process's lifecycle fields with an
RWMutexso the status endpoint and the check-xray job can no longer data-race the start/wait goroutines.Why
cmd,doneandexitErrwere written byStart/startCommandand thewaitForCommandgoroutine whileIsRunning/GetErr/GetResult/Stopread them concurrently from other goroutines (the status endpoint and the check-xray job) — a data race, reproducible under-race.Scope
Wait/Signal/Kill) on the local copy without holding the lockIsRunningnow uses thedonechannel as the exit signal instead of readingcmd.ProcessState, which races withcmd.WaitValidation
-raceinternal/xraybuild, vet and tests passRisk
Low. Locking-only change around the existing lifecycle logic; no behaviour change beyond removing the race.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.