mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-26 17:03:02 +00:00
Fix: Remove udp connection twice
This commit is contained in:
parent
27224868ab
commit
3c7189a3e7
@ -161,6 +161,11 @@ type udpConn struct {
|
|||||||
done *done.Instance
|
done *done.Instance
|
||||||
uplink stats.Counter
|
uplink stats.Counter
|
||||||
downlink stats.Counter
|
downlink stats.Counter
|
||||||
|
inactive bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *udpConn) setInactive() {
|
||||||
|
c.inactive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *udpConn) updateActivity() {
|
func (c *udpConn) updateActivity() {
|
||||||
@ -328,7 +333,11 @@ func (w *udpWorker) callback(b *buf.Buffer, source net.Destination, originalDest
|
|||||||
newError("connection ends").Base(err).WriteToLog(session.ExportIDToError(ctx))
|
newError("connection ends").Base(err).WriteToLog(session.ExportIDToError(ctx))
|
||||||
}
|
}
|
||||||
conn.Close()
|
conn.Close()
|
||||||
|
// conn not removed by checker TODO may be lock worker here is better
|
||||||
|
if !conn.inactive {
|
||||||
|
conn.setInactive()
|
||||||
w.removeConn(id)
|
w.removeConn(id)
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -356,8 +365,11 @@ func (w *udpWorker) clean() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for addr, conn := range w.activeConn {
|
for addr, conn := range w.activeConn {
|
||||||
if nowSec-atomic.LoadInt64(&conn.lastActivityTime) > 300 {
|
if nowSec-atomic.LoadInt64(&conn.lastActivityTime) > 5*60 { // TODO Timeout too small
|
||||||
|
if !conn.inactive {
|
||||||
|
conn.setInactive()
|
||||||
delete(w.activeConn, addr)
|
delete(w.activeConn, addr)
|
||||||
|
}
|
||||||
conn.Close()
|
conn.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user