Merge pull request #1000 from cvium/fix_object_disposed

Don't close the socket response multiple times
This commit is contained in:
Vasily 2019-02-25 16:52:31 +03:00 committed by GitHub
commit b3438559cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -164,33 +164,19 @@ namespace Jellyfin.Server.SocketSharp
Endpoint = endpoint
});
await ReceiveWebSocketAsync(ctx, socket).ConfigureAwait(false);
await socket.StartReceive().ConfigureAwait(false);
}
}
else
{
_logger.LogWarning("Web socket connection not allowed");
ctx.Response.StatusCode = 401;
ctx.Response.Close();
TryClose(ctx, 401);
}
}
catch (Exception ex)
{
_logger.LogError(ex, "AcceptWebSocketAsync error");
ctx.Response.StatusCode = 500;
ctx.Response.Close();
}
}
private async Task ReceiveWebSocketAsync(HttpListenerContext ctx, SharpWebSocket socket)
{
try
{
await socket.StartReceive().ConfigureAwait(false);
}
finally
{
TryClose(ctx, 200);
TryClose(ctx, 500);
}
}
@ -201,10 +187,6 @@ namespace Jellyfin.Server.SocketSharp
ctx.Response.StatusCode = statusCode;
ctx.Response.Close();
}
catch (ObjectDisposedException)
{
// TODO: Investigate and properly fix.
}
catch (Exception ex)
{
_logger.LogError(ex, "Error closing web socket response");