Skip to content

Commit

Permalink
fix deadlock in close
Browse files Browse the repository at this point in the history
Signed-off-by: Yilun <[email protected]>
  • Loading branch information
yilunzhang committed Nov 21, 2024
1 parent ec9e3ee commit 4aa759c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ func (c *TunaSessionClient) listenNet(i int) {
for {
netConn, err := c.listeners[i].Accept()
if err != nil {
if c.IsClosed() {
if c.isClosed {
return
}
log.Printf("Accept connection error: %v", err)
Expand Down Expand Up @@ -877,7 +877,7 @@ func (c *TunaSessionClient) removeClosedSessions() {
for {
time.Sleep(time.Second)

if c.IsClosed() {
if c.isClosed {
return
}

Expand Down Expand Up @@ -1011,7 +1011,7 @@ func (c *TunaSessionClient) dialTcpConn(ctx context.Context, remoteAddr string,
}

func (c *TunaSessionClient) reconnect(remoteAddr string, sessionID []byte, i int, pubAddrs *PubAddrs, config *nkn.DialConfig) (conn *Conn, err error) {
if c.IsClosed() {
if c.isClosed {
return nil, ErrClosed
}
sessKey := sessionKey(remoteAddr, sessionID)
Expand Down
2 changes: 1 addition & 1 deletion udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (c *TunaSessionClient) DialUDPWithConfig(remoteAddr string, config *nkn.Dia
for {
udpSess.handleTcpMsg(udpSess.tcpConn, sessionKey(remoteAddr, sessionID))

if c.IsClosed() || udpSess.udpConn.IsClosed() {
if c.isClosed || udpSess.udpConn.IsClosed() {
break
}
if c.config.ReconnectRetries == 0 {
Expand Down
6 changes: 3 additions & 3 deletions udpsession.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func newUdpSession(ts *TunaSessionClient, isListener bool) *UdpSession {
}

func (us *UdpSession) DialUpSession(listenerNknAddr string, sessionID []byte, config *nkn.DialConfig) (err error) {
if us.ts.IsClosed() {
if us.ts.isClosed {
return ErrClosed
}

Expand Down Expand Up @@ -203,7 +203,7 @@ func (us *UdpSession) GetUDPConn() *tuna.EncryptUDPConn {
}

func (us *UdpSession) GetEstablishedUDPConn() (*tuna.EncryptUDPConn, error) {
if us.ts.IsClosed() {
if us.ts.isClosed {
return nil, ErrClosed
}
conn := us.GetUDPConn()
Expand Down Expand Up @@ -315,7 +315,7 @@ func (us *UdpSession) Write(b []byte) (int, error) {
}

func (us *UdpSession) SetDeadline(t time.Time) error {
if us.ts.IsClosed() {
if us.ts.isClosed {
return ErrClosed
}

Expand Down

0 comments on commit 4aa759c

Please sign in to comment.