private void DeviceOverload(AerospikeException ae) { node.IncrErrorCount(); if (iteration <= maxRetries && (totalWatch == null || totalWatch.ElapsedMilliseconds < totalTimeout)) { int status = Interlocked.CompareExchange(ref state, RETRY, IN_PROGRESS); if (status == IN_PROGRESS) { node.PutAsyncConnection(conn); Retry(ae); } else { AlreadyCompleted(status); } } else { int status = Interlocked.CompareExchange(ref state, FAIL_APPLICATION_ERROR, IN_PROGRESS); if (status == IN_PROGRESS) { node.PutAsyncConnection(conn); FailCommand(ae); } else { AlreadyCompleted(status); } } }
public AsyncConnection(IPEndPoint address, AsyncNode node) { try { socket = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp); } catch (Exception e) { node.DecrAsyncConnTotal(); node.IncrErrorCount(); throw new AerospikeException.Connection(e); } node.IncrAsyncConnOpened(); try { socket.NoDelay = true; // Docs say Blocking flag is ignored for async operations. // socket.Blocking = false; if (ZeroBuffers) { // Avoid internal TCP send/receive buffers. // Use application buffers directly. socket.SendBufferSize = 0; socket.ReceiveBufferSize = 0; } lastUsed = DateTime.UtcNow; } catch (Exception e) { socket.Dispose(); node.DecrAsyncConnTotal(); node.IncrAsyncConnClosed(); node.IncrErrorCount(); throw new AerospikeException.Connection(e); } }