Minor fixes

This commit is contained in:
世界 2026-07-07 15:36:21 +08:00
parent 14c8f75f7a
commit c17af6ee8c
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
13 changed files with 357 additions and 181 deletions

View file

@ -42,16 +42,22 @@ func (c *gLazyConn) HandshakeContext(ctx context.Context) error {
wq waiter.Queue
endpoint tcpip.Endpoint
)
handshakeCtx, cancel := context.WithCancel(ctx)
go func() {
select {
case <-c.parentCtx.Done():
wq.Notify(wq.Events())
case <-handshakeCtx.Done():
}
}()
var cancel context.CancelFunc
if parentDone := c.parentCtx.Done(); parentDone != nil {
var handshakeCtx context.Context
handshakeCtx, cancel = context.WithCancel(ctx)
go func() {
select {
case <-parentDone:
wq.Notify(wq.Events())
case <-handshakeCtx.Done():
}
}()
}
endpoint, err := c.request.CreateEndpoint(&wq)
cancel()
if cancel != nil {
cancel()
}
if err != nil {
gErr := gonet.TranslateNetstackError(err)
c.handshakeErr = gErr