Skip to content

Commit b4c8216

Browse files
committed
[Modify] Lock it
1 parent 41d8949 commit b4c8216

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

websocket-sharp/Net/HttpListener.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -822,13 +822,15 @@ public HttpListenerContext EndGetContext (IAsyncResult asyncResult)
822822
throw new ArgumentException (msg, "asyncResult");
823823
}
824824

825-
if (ares.EndCalled) {
826-
var msg = "This IAsyncResult instance cannot be reused.";
825+
lock (ares.SyncRoot) {
826+
if (ares.EndCalled) {
827+
var msg = "This IAsyncResult instance cannot be reused.";
827828

828-
throw new InvalidOperationException (msg);
829-
}
829+
throw new InvalidOperationException (msg);
830+
}
830831

831-
ares.EndCalled = true;
832+
ares.EndCalled = true;
833+
}
832834

833835
if (!ares.IsCompleted)
834836
ares.AsyncWaitHandle.WaitOne ();

0 commit comments

Comments
 (0)