Skip to content

Commit

Permalink
fix: TLS1.2 non-block read
Browse files Browse the repository at this point in the history
  • Loading branch information
andyl committed Apr 23, 2024
1 parent 2900b77 commit 79b2a67
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 404 deletions.
10 changes: 6 additions & 4 deletions pkg/tls/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type Conn struct {
// isHandshakeComplete is true implies handshakeErr == nil.
isHandshakeComplete atomic.Bool
isWaitClientFinished atomic.Bool
handshakeState int8
hs interface{ handshake() error }
readClientFinished func() error
// constant after handshake; protected by handshakeMutex
handshakeMutex sync.Mutex
Expand Down Expand Up @@ -1583,13 +1585,13 @@ func (c *Conn) handshakeContext(ctx context.Context) (ret error) {
return nil
}

if c.isWaitClientFinished.Load() {
/*if c.isWaitClientFinished.Load() {
if err := c.readClientFinished(); err != nil {
return err
}
c.isHandshakeComplete.Store(true)
return nil
}
}*/

/* if c.isHandshakeComplete.Load() {
return nil
Expand Down Expand Up @@ -1658,8 +1660,8 @@ func (c *Conn) handshakeContext(ctx context.Context) (ret error) {
c.flush()
}

if c.isWaitClientFinished.Load() {
return ErrNotEnough
if !c.isHandshakeComplete.Load() {
return nil
}

/* if c.handshakeErr == nil && !c.isHandshakeComplete.Load() {
Expand Down
Loading

0 comments on commit 79b2a67

Please sign in to comment.