Skip to content

fix(xray): synchronize process status checks - #86

Open
dr-hoseyn wants to merge 1 commit into
PasarGuard:devfrom
dr-hoseyn:fix/xray-started-process-race
Open

fix(xray): synchronize process status checks#86
dr-hoseyn wants to merge 1 commit into
PasarGuard:devfrom
dr-hoseyn:fix/xray-started-process-race

Conversation

@dr-hoseyn

@dr-hoseyn dr-hoseyn commented Sep 3, 2026

Copy link
Copy Markdown

Core.Started reads exec.Cmd.ProcessState while Cmd.Wait writes it, and it reads the process pointer while lifecycle methods replace it. Health checks and API status requests can therefore race with process exit, stop, or restart.

This change protects process status checks with the core mutex and uses the existing waitDone channel to observe process exit instead of reading ProcessState. Start and Stop call a lock-held helper so they do not recursively acquire the mutex. Regression tests use a real child process to cover exit, concurrent polling during stop/replacement, and duplicate-start rejection without requiring an installed Xray binary.

Validation:

  • go test ./backend/xray -run '^TestCoreStarted' -count=25 -timeout=180s — passed
  • go vet ./backend/xray — passed
  • git diff --check — passed
  • Full local Xray package run reaches the existing integration tests, then fails because /usr/local/bin/xray is unavailable on this Windows host.
  • Local -race execution is unavailable because this host has no C compiler. The PR adds a focused Linux CI race check; GitHub currently marks the fork workflow as action_required, pending maintainer approval.

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 4a7bf926-0196-4e33-96aa-5fdc89bc1f73

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dr-hoseyn
dr-hoseyn marked this pull request as ready for review September 3, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant