Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Dispose logger factory when disposing hosting engine #316

Closed
wants to merge 1 commit into from

Conversation

kichalla
Copy link
Member

@kichalla kichalla commented Aug 3, 2015

@Tratcher This is related to the PR aspnet/Logging#162

@@ -87,6 +88,7 @@ public virtual IDisposable Start()
_applicationLifetime.NotifyStopping();
server.Dispose();
_applicationLifetime.NotifyStopped();
loggerFactory.Dispose();
Copy link
Member Author

Choose a reason for hiding this comment

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

It feels odd to just dispose this service here. Not sure if there are any other services which need similar requirement.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, this is weird. Isn't this what DI scopes are for? Would it make sense to create a scope on line 66 and dispose it here? Then any scoped services would be disposed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm...I have seen DI scopes used in per-request kind of scenarios where as logger factory here is an application wide service. (thinking of it in a different way...the application start and shutdown itself is a scope and probably we should just dispose off all disposable application services as how DI scope would do).

Copy link
Member

Choose a reason for hiding this comment

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

Consider in the test scenario where we start multiple TestHost/Servers in one process. HostingEngine is only a scoped subset of an actual application, so I think DI scopes are an appropriate concept here. Per-request scopes would be nested inside of the per-HostingEngine scopes.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

Copy link
Member Author

Choose a reason for hiding this comment

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

@HaoK and I discussed about this and agreed that disposing loggerfactory alone for this PR is fine and we will file another issue to handle disposing all the hosting engine services as it requires more refactoring than expected.

@Tratcher

Copy link
Member

Choose a reason for hiding this comment

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

Why bother with the partial fix then? It's not urgent.

Copy link
Member Author

Choose a reason for hiding this comment

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

The following PR depends on this
aspnet/Logging#162

Copy link
Member

Choose a reason for hiding this comment

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

No, Hosting depends on Logging. That Logging PR is nice to have, but calling Dispose not a blocking issue for beta7.

Your partial fix here does not contribute towards the full fix, so don't bother.

@kichalla
Copy link
Member Author

kichalla commented Aug 6, 2015

@rynowak

@kichalla kichalla force-pushed the kiran/dispose-loggerfactory branch 4 times, most recently from 6353035 to 487afae Compare August 6, 2015 22:40
@kichalla
Copy link
Member Author

Closing this PR as it will be handled as part of fix for #322

@kichalla kichalla closed this Aug 10, 2015
@kichalla kichalla deleted the kiran/dispose-loggerfactory branch August 4, 2016 18:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants