@@ -72,7 +72,7 @@ type Conn struct {
72
72
maximumTransmissionUnit int
73
73
paddingLengthGenerator func (uint ) uint
74
74
75
- handshakeCompletedSuccessfully atomic.Value
75
+ handshakeCompletedSuccessfully atomic.Bool
76
76
handshakeMutex sync.Mutex
77
77
handshakeDone chan struct {}
78
78
@@ -1077,14 +1077,12 @@ func (c *Conn) notify(ctx context.Context, level alert.Level, desc alert.Descrip
1077
1077
})
1078
1078
}
1079
1079
1080
- func (c * Conn ) setHandshakeCompletedSuccessfully () {
1081
- c .handshakeCompletedSuccessfully .Store ( struct { bool }{ true } )
1080
+ func (c * Conn ) setHandshakeCompletedSuccessfully () bool {
1081
+ return c .handshakeCompletedSuccessfully .CompareAndSwap ( false , true )
1082
1082
}
1083
1083
1084
1084
func (c * Conn ) isHandshakeCompletedSuccessfully () bool {
1085
- boolean , _ := c .handshakeCompletedSuccessfully .Load ().(struct { bool })
1086
-
1087
- return boolean .bool
1085
+ return c .handshakeCompletedSuccessfully .Load ()
1088
1086
}
1089
1087
1090
1088
//nolint:cyclop,gocognit,contextcheck
@@ -1099,8 +1097,7 @@ func (c *Conn) handshake(
1099
1097
done := make (chan struct {})
1100
1098
ctxRead , cancelRead := context .WithCancel (context .Background ())
1101
1099
cfg .onFlightState = func (_ flightVal , s handshakeState ) {
1102
- if s == handshakeFinished && ! c .isHandshakeCompletedSuccessfully () {
1103
- c .setHandshakeCompletedSuccessfully ()
1100
+ if s == handshakeFinished && c .setHandshakeCompletedSuccessfully () {
1104
1101
close (done )
1105
1102
}
1106
1103
}
0 commit comments