Skip to content

Commit

Permalink
Merge pull request #494 from TarsCloud/fix/close/conn
Browse files Browse the repository at this point in the history
fix: Setting the read timeout configuration is unreasonable, causing the service to exit and the connection not closed
  • Loading branch information
lbbniu authored Jun 28, 2023
2 parents 2f562ac + 95554d7 commit ef30e68
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tars/transport/tcphandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ func (t *tcpHandler) CloseIdles(n int64) bool {
TLOG.Debugf("num invoke %d %v", atomic.LoadInt32(&conn.numInvoke), conn.idleTime+n > time.Now().Unix())
if atomic.LoadInt32(&conn.numInvoke) > 0 || conn.idleTime+n > time.Now().Unix() {
allClosed = false
return true
}
conn.conn.Close()
return true
})
return allClosed
Expand Down Expand Up @@ -235,8 +237,8 @@ func (t *tcpHandler) recv(connSt *connInfo) {
}
connSt.idleTime = time.Now().Unix()
n, err = conn.Read(buffer)
// TLOG.Debugf("%s closed: %d, read %d, nil buff: %d, err: %v", t.server.config.Address, atomic.LoadInt32(&t.server.isClosed), n, len(currBuffer), err)
if err != nil {
TLOG.Debugf("%s closed: %d, read %d, nil buff: %d, err: %v", t.server.config.Address, atomic.LoadInt32(&t.server.isClosed), n, len(currBuffer), err)
if atomic.LoadInt32(&t.server.isClosed) == 1 && currBuffer == nil {
return
}
Expand Down

0 comments on commit ef30e68

Please sign in to comment.