Fixed thread visibility issues in the client handshake when reconnecting
This commit is contained in:
parent
c13fb205cf
commit
7db6a45437
|
@ -25,16 +25,19 @@ import dorkbox.network.exceptions.ClientTimedOutException
|
||||||
import io.aeron.FragmentAssembler
|
import io.aeron.FragmentAssembler
|
||||||
import io.aeron.logbuffer.FragmentHandler
|
import io.aeron.logbuffer.FragmentHandler
|
||||||
import io.aeron.logbuffer.Header
|
import io.aeron.logbuffer.Header
|
||||||
import mu.KLogger
|
|
||||||
import org.agrona.DirectBuffer
|
import org.agrona.DirectBuffer
|
||||||
import java.security.SecureRandom
|
import java.security.SecureRandom
|
||||||
|
|
||||||
internal class ClientHandshake<CONNECTION: Connection>(private val logger: KLogger,
|
internal class ClientHandshake<CONNECTION: Connection>(private val config: Configuration,
|
||||||
private val config: Configuration,
|
|
||||||
private val crypto: CryptoManagement,
|
private val crypto: CryptoManagement,
|
||||||
private val endPoint: EndPoint<CONNECTION>) {
|
private val endPoint: EndPoint<CONNECTION>) {
|
||||||
|
|
||||||
|
// @Volatile is used BECAUSE suspension of coroutines can continue on a DIFFERENT thread. We want to make sure that thread visibility is
|
||||||
|
// correct when this happens. There are no race-conditions to be wary of.
|
||||||
|
|
||||||
// a one-time key for connecting
|
// a one-time key for connecting
|
||||||
private val oneTimePad = SecureRandom().nextInt()
|
private val oneTimePad = SecureRandom().nextInt()
|
||||||
|
private val handler: FragmentHandler
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
private var connectionHelloInfo: ClientConnectionInfo? = null
|
private var connectionHelloInfo: ClientConnectionInfo? = null
|
||||||
|
@ -45,7 +48,7 @@ internal class ClientHandshake<CONNECTION: Connection>(private val logger: KLogg
|
||||||
@Volatile
|
@Volatile
|
||||||
private var failed: Exception? = null
|
private var failed: Exception? = null
|
||||||
|
|
||||||
private var handler: FragmentHandler
|
@Volatile
|
||||||
private var sessionId: Int = 0
|
private var sessionId: Int = 0
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user