Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix deadlock in close #79

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading