tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From florianhockm...@apache.org
Subject [tinkerpop] branch master updated: Fix potentially harmful timing issue: _writeInProgress could be observed by BeginSendingMessages to indicate that the loop in SendMessagesFromQueueAsync is still "in flight" while in reality, it has already exited.
Date Mon, 20 May 2019 06:27:49 GMT
This is an automated email from the ASF dual-hosted git repository.

florianhockmann pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


The following commit(s) were added to refs/heads/master by this push:
     new f6038e3  Fix potentially harmful timing issue: _writeInProgress could be observed
by BeginSendingMessages to indicate that the loop in SendMessagesFromQueueAsync is still "in
flight" while in reality, it has already exited.
     new 0d38dba  Merge pull request #1114 from danielcweber/TINKERPOP-2217 CTR
f6038e3 is described below

commit f6038e38937bb308f736f45603d32074f10bf7d3
Author: Daniel C. Weber <dw@exram.de>
AuthorDate: Mon May 13 23:44:23 2019 +0200

    Fix potentially harmful timing issue: _writeInProgress could be observed by BeginSendingMessages
to indicate that the loop in SendMessagesFromQueueAsync is still "in flight" while in reality,
it has already exited.
---
 gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
index 5a35465..b9845c7 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
@@ -194,6 +194,13 @@ namespace Gremlin.Net.Driver
                 }
             }
             Interlocked.CompareExchange(ref _writeInProgress, 0, 1);
+
+            // Since the loop ended and the write in progress was set to 0
+            // a new item could have been added, write queue can contain items at this time
+            if (!_writeQueue.IsEmpty && Interlocked.CompareExchange(ref _writeInProgress,
1, 0) == 0)
+            {
+                await SendMessagesFromQueueAsync().ConfigureAwait(false);
+            }
         }
 
         private async Task CloseConnectionBecauseOfFailureAsync(Exception exception)


Mime
View raw message