Skip to content

Remove NOTIFY_SOCKET clear side effect from SystemdNotifier ctor#127316

Open
cincuranet wants to merge 1 commit intodotnet:mainfrom
cincuranet:systemd
Open

Remove NOTIFY_SOCKET clear side effect from SystemdNotifier ctor#127316
cincuranet wants to merge 1 commit intodotnet:mainfrom
cincuranet:systemd

Conversation

@cincuranet
Copy link
Copy Markdown
Contributor

Move the NOTIFY_SOCKET clear out of SystemdNotifier.GetNotifySocketPath and into the ISystemdNotifier DI factory in AddSystemdLifetime. The public parameterless ctor is now a pure read; the env var is only mutated when hosting is actually wired up, and notifier construction stays lazy (DI resolves it during Host build via IHostLifetime).

Follow-up from #125520.

Move the NOTIFY_SOCKET clear out of SystemdNotifier.GetNotifySocketPath
and into the ISystemdNotifier DI factory in AddSystemdLifetime. The
public parameterless ctor is now a pure read; the env var is only
mutated when hosting is actually wired up, and notifier construction
stays lazy (DI resolves it during Host build via IHostLifetime).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@cincuranet cincuranet added this to the 11.0.0 milestone Apr 23, 2026
@cincuranet cincuranet self-assigned this Apr 23, 2026
Copilot AI review requested due to automatic review settings April 23, 2026 10:29
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-extensions-hosting
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the side effect of clearing NOTIFY_SOCKET from SystemdNotifier construction and moves that mutation into the AddSystemdLifetime DI registration path, so the public parameterless SystemdNotifier ctor becomes a pure read of the environment.

Changes:

  • Removed NOTIFY_SOCKET clearing from SystemdNotifier.GetNotifySocketPath.
  • Updated AddSystemdLifetime to register ISystemdNotifier via a factory that constructs SystemdNotifier, then clears NOTIFY_SOCKET.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs Removes env-var mutation from notifier construction, keeping it as a read/normalize operation.
src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdHostBuilderExtensions.cs Moves NOTIFY_SOCKET clearing into the Systemd hosting DI wiring so it only happens when systemd lifetime is actually configured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants