Skip to content

Commit ef30e68

Browse files
authored
Merge pull request #494 from TarsCloud/fix/close/conn
fix: Setting the read timeout configuration is unreasonable, causing the service to exit and the connection not closed
2 parents 2f562ac + 95554d7 commit ef30e68

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tars/transport/tcphandler.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ func (t *tcpHandler) CloseIdles(n int64) bool {
194194
TLOG.Debugf("num invoke %d %v", atomic.LoadInt32(&conn.numInvoke), conn.idleTime+n > time.Now().Unix())
195195
if atomic.LoadInt32(&conn.numInvoke) > 0 || conn.idleTime+n > time.Now().Unix() {
196196
allClosed = false
197+
return true
197198
}
199+
conn.conn.Close()
198200
return true
199201
})
200202
return allClosed
@@ -235,8 +237,8 @@ func (t *tcpHandler) recv(connSt *connInfo) {
235237
}
236238
connSt.idleTime = time.Now().Unix()
237239
n, err = conn.Read(buffer)
238-
// 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)
239240
if err != nil {
241+
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)
240242
if atomic.LoadInt32(&t.server.isClosed) == 1 && currBuffer == nil {
241243
return
242244
}

0 commit comments

Comments
 (0)