aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-09-08 21:15:31 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-09-08 21:15:31 -0400
commita2dc5e090bac15ee2dd7c83281aa9fada1f74734 (patch)
tree5f6da5aa9c9faed8a4c0ff05d504043adad3efc3 /MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs
parent09bffa1b560f2d9e43735f3c6de881e17b2c245f (diff)
update translations
Diffstat (limited to 'MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs')
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs17
1 files changed, 6 insertions, 11 deletions
diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs
index e655d415a..19bc93861 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs
@@ -14,8 +14,8 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
{
public class WebSocketSharpListener : IHttpListener
{
- private WebSocketSharp.Net.HttpListener _listener;
- private readonly AutoResetEvent _listenForNextRequest = new AutoResetEvent(false);
+ private HttpListener _listener;
+ private readonly ManualResetEventSlim _listenForNextRequest = new ManualResetEventSlim(false);
private readonly ILogger _logger;
private readonly Action<string> _endpointListener;
@@ -59,11 +59,12 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
while (IsListening)
{
if (_listener == null) return;
+ _listenForNextRequest.Reset();
try
{
_listener.BeginGetContext(ListenerCallback, _listener);
- _listenForNextRequest.WaitOne();
+ _listenForNextRequest.Wait();
}
catch (Exception ex)
{
@@ -77,6 +78,8 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
// Handle the processing of a request in here.
private void ListenerCallback(IAsyncResult asyncResult)
{
+ _listenForNextRequest.Set();
+
var listener = asyncResult.AsyncState as HttpListener;
HttpListenerContext context;
@@ -103,14 +106,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
_logger.Warn(errMsg);
return;
}
- finally
- {
- // Once we know we have a request (or exception), we signal the other thread
- // so that it calls the BeginGetContext() (or possibly exits if we're not
- // listening any more) method to start handling the next incoming request
- // while we continue to process this request on a different thread.
- _listenForNextRequest.Set();
- }
Task.Factory.StartNew(() => InitTask(context));
}