This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Description
If multiple addresses are being used in ServerFactory and an exception is thrown in engine.CreateServer, then the proceeding disposables are not cleaned up properly. Consider changing the method implementation to something similar to:
public IDisposable Start(IServerInformation serverInformation, Func<IFeatureCollection, Task> application)
{
var disposables = new List<IDisposable>();
var dispose = new Disposable(() =>
{
foreach (var disposable in disposables)
{
disposable.Dispose();
}
});
var information = (ServerInformation)serverInformation;
var engine = new KestrelEngine(_libraryManager);
engine.Start(1);
try
{
foreach (var address in information.Addresses)
{
disposables.Add(engine.CreateServer(
address.Scheme,
address.Host,
address.Port,
async frame =>
{
var request = new ServerRequest(frame);
await application.Invoke(request.Features);
}));
}
disposables.Add(engine);
return dispose;
}
catch (Exception)
{
dispose.Dispose();
throw;
}
}