Github user jorgebay commented on a diff in the pull request:

    https://github.com/apache/tinkerpop/pull/704#discussion_r137213383
  
    --- Diff: gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs ---
    @@ -74,6 +85,36 @@ private void AddConnection(Connection connection)
                 }
             }
     
    +        private void ConsiderUnavailable()
    +        {
    +            CloseAndRemoveAllConnections();
    +        }
    +
    +        private void CloseAndRemoveAllConnections()
    +        {
    +            lock (_connectionsLock)
    +            {
    +                TeardownAsync().WaitUnwrap();
    +                RemoveAllConnections();
    +            }
    +        }
    +
    +        private void RemoveAllConnections()
    +        {
    +            while (!_connections.IsEmpty)
    --- End diff --
    
    Using `TryTake()` and `IsEmpty` can create race conditions.
    Use `while (bag.TryTake(out c))` instead.


---

Reply via email to