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 2 ConnectionPool inconcistencies CTR
Date Sun, 13 Jan 2019 17:39:26 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 304795f  Fix 2 ConnectionPool inconcistencies CTR
304795f is described below

commit 304795f93cb521d0fcadccbc32ad9eb7f80cc454
Author: Florian Hockmann <fh@florian-hockmann.de>
AuthorDate: Sun Jan 13 18:37:19 2019 +0100

    Fix 2 ConnectionPool inconcistencies CTR
    
    ConnectionPool.NrConnections could return -1 if it was called when the
    pool is populated at the same time.
    ReturnConnectionIfOpen() called DefinitelyDestroyConnection() after
    having already destroyed all connections by calling ConsiderUnavailable.
---
 gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
index 242def8..708580b 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
@@ -49,7 +49,14 @@ namespace Gremlin.Net.Driver
             PopulatePoolAsync().WaitUnwrap();
         }
         
-        public int NrConnections => Interlocked.CompareExchange(ref _nrConnections, PoolEmpty,
PoolEmpty);               
+        public int NrConnections
+        {
+            get
+            {
+                var nrConnections = Interlocked.CompareExchange(ref _nrConnections, PoolEmpty,
PoolEmpty);
+                return nrConnections < 0 ? 0 : nrConnections;
+            }
+        }
         
         public async Task<IConnection> GetAvailableConnectionAsync()
         {
@@ -144,7 +151,6 @@ namespace Gremlin.Net.Driver
         {
             if (connection.IsOpen) return;
             ConsiderUnavailable();
-            DefinitelyDestroyConnection(connection);
         }
 
         private void ConsiderUnavailable()


Mime
View raw message