From 1853c711148539ac12f50eea1a717eb4651478b4 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Mon, 10 Mar 2014 08:32:59 -0700 Subject: [PATCH] Narrow ping write lock. --- src/Microsoft.Net.WebSockets/CommonWebSocket.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs index 2edd8f6e47..b4315644b2 100644 --- a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs +++ b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs @@ -156,10 +156,9 @@ namespace Microsoft.Net.WebSockets private async void SendKeepAliveAsync() { // Check concurrent writes, pings & pongs, or closes - bool lockAquired = await _writeLock.WaitAsync(TimeSpan.FromMinutes(1)); // TODO: Wait up to KeepAliveInterval? - if (!lockAquired) + if (!_writeLock.Wait(0)) { - // Pings aren't that important, discard them if we can't take the lock. + // Sending real data is better than a ping, discard it. return; } try