Connection timeout is based from when connection is created

This commit is contained in:
Robinson 2023-10-19 23:42:08 +02:00
parent 0e16747dc2
commit 83a9a5762d
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
1 changed files with 6 additions and 1 deletions

View File

@ -56,7 +56,8 @@ open class Connection(connectionParameters: ConnectionParams<*>) {
// only accessed on a single thread!
private val connectionExpirationTimoutNanos = endPoint.config.connectionExpirationTimoutNanos
private var connectionTimeoutTimeNanos = 0L
// the timeout starts from when the connection is first created, so that we don't get "instant" timeouts when the server rejects a connection
private var connectionTimeoutTimeNanos = System.nanoTime()
/**
* There can be concurrent writes to the network stack, at most 1 per connection. Each connection has its own logic on the remote endpoint,
@ -145,6 +146,10 @@ open class Connection(connectionParameters: ConnectionParams<*>) {
// counter, which is also transmitted as an optimized int. (which is why it starts at 0, so the transmitted bytes are small)
internal val aes_gcm_iv = atomic(0)
// Used to track that this connection WILL be closed, but has not yet been closed.
@Volatile
internal var closeRequested = false
init {
// NOTE: subscriptions (ie: reading from buffers, etc) are not thread safe! Because it is ambiguous HOW EXACTLY they are unsafe,