Skip to content

Commit

Permalink
Fix non-zero linger not handling ACK after close call
Browse files Browse the repository at this point in the history
Signed-off-by: Yilun <[email protected]>
  • Loading branch information
yilunzhang committed Feb 11, 2020
1 parent bb65883 commit 7d840c6
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,14 @@ func (session *Session) sendClosePacket() error {
}

func (session *Session) handleClosePacket() error {
session.readCancel()
session.writeCancel()
session.cancel()

session.Lock()
session.isClosed = true
session.Unlock()
session.close()

return nil
}

Expand Down Expand Up @@ -843,16 +847,9 @@ func (session *Session) Write(b []byte) (_ int, e error) {
return bytesSent, nil
}

func (session *Session) close() {
session.cancel()
func (session *Session) Close() error {
session.readCancel()
session.writeCancel()
}

func (session *Session) Close() error {
session.Lock()
session.isClosed = true
session.Unlock()

timeout := make(chan struct{})
if session.config.Linger > 0 {
Expand Down Expand Up @@ -894,7 +891,11 @@ func (session *Session) Close() error {
log.Println(err)
}

session.close()
session.cancel()

session.Lock()
session.isClosed = true
session.Unlock()
}()

return nil
Expand Down

0 comments on commit 7d840c6

Please sign in to comment.