Merge pull request #1000 from cvium/fix_object_disposed
Don't close the socket response multiple times
This commit is contained in:
commit
b3438559cc
|
@ -164,33 +164,19 @@ namespace Jellyfin.Server.SocketSharp
|
||||||
Endpoint = endpoint
|
Endpoint = endpoint
|
||||||
});
|
});
|
||||||
|
|
||||||
await ReceiveWebSocketAsync(ctx, socket).ConfigureAwait(false);
|
await socket.StartReceive().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Web socket connection not allowed");
|
_logger.LogWarning("Web socket connection not allowed");
|
||||||
ctx.Response.StatusCode = 401;
|
TryClose(ctx, 401);
|
||||||
ctx.Response.Close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "AcceptWebSocketAsync error");
|
_logger.LogError(ex, "AcceptWebSocketAsync error");
|
||||||
ctx.Response.StatusCode = 500;
|
TryClose(ctx, 500);
|
||||||
ctx.Response.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task ReceiveWebSocketAsync(HttpListenerContext ctx, SharpWebSocket socket)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await socket.StartReceive().ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
TryClose(ctx, 200);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,10 +187,6 @@ namespace Jellyfin.Server.SocketSharp
|
||||||
ctx.Response.StatusCode = statusCode;
|
ctx.Response.StatusCode = statusCode;
|
||||||
ctx.Response.Close();
|
ctx.Response.Close();
|
||||||
}
|
}
|
||||||
catch (ObjectDisposedException)
|
|
||||||
{
|
|
||||||
// TODO: Investigate and properly fix.
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Error closing web socket response");
|
_logger.LogError(ex, "Error closing web socket response");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user