Commit 9a265ed1 authored by AlexStocks's avatar AlexStocks

forbid close udp session in OnCron

parent 2ec937f9
......@@ -10,6 +10,10 @@
## develop history ##
---
- 2018/03/16
> bug fix
* forbid close udp session in OnCron
- 2018/03/14
> init
......
......@@ -161,23 +161,24 @@ func (this *EchoMessageHandler) OnMessage(session getty.Session, udpCtx interfac
func (this *EchoMessageHandler) OnCron(session getty.Session) {
var (
flag bool
//flag bool
active time.Time
)
this.rwlock.RLock()
if _, ok := this.sessionMap[session]; ok {
active = session.GetActive()
if conf.sessionTimeout.Nanoseconds() < time.Since(active).Nanoseconds() {
flag = true
log.Warn("session{%s} timeout{%s}, reqNum{%d}",
//flag = true
log.Error("session{%s} timeout{%s}, reqNum{%d}",
session.Stat(), time.Since(active).String(), this.sessionMap[session].reqNum)
}
}
this.rwlock.RUnlock()
if flag {
this.rwlock.Lock()
delete(this.sessionMap, session)
this.rwlock.Unlock()
session.Close()
}
// udp session是根据本地udp socket fd生成的,如果关闭则连同socket也一同关闭了
//if flag {
// this.rwlock.Lock()
// delete(this.sessionMap, session)
// this.rwlock.Unlock()
// session.Close()
//}
}
......@@ -6,7 +6,8 @@ AppName = "ECHO-SERVER"
Host = "127.0.0.1"
# Host = "192.168.35.1"
# Host = "192.168.8.3"
Ports = ["10000", "20000"]
# Ports = ["10000", "20000"]
Ports = ["10000"]
ProfilePort = 10086
# session
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment