Remove NOTIFY_SOCKET clear side effect from SystemdNotifier ctor#127316
Open
cincuranet wants to merge 1 commit intodotnet:mainfrom
Open
Remove NOTIFY_SOCKET clear side effect from SystemdNotifier ctor#127316cincuranet wants to merge 1 commit intodotnet:mainfrom
NOTIFY_SOCKET clear side effect from SystemdNotifier ctor#127316cincuranet wants to merge 1 commit intodotnet:mainfrom
Conversation
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>
Contributor
|
Tagging subscribers to this area: @dotnet/area-extensions-hosting |
Contributor
There was a problem hiding this comment.
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_SOCKETclearing fromSystemdNotifier.GetNotifySocketPath. - Updated
AddSystemdLifetimeto registerISystemdNotifiervia a factory that constructsSystemdNotifier, then clearsNOTIFY_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. |
This was referenced Apr 23, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Move the
NOTIFY_SOCKETclear out ofSystemdNotifier.GetNotifySocketPathand into theISystemdNotifierDI factory inAddSystemdLifetime. 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 duringHostbuild viaIHostLifetime).Follow-up from #125520.