Commit c097d154 authored by alexstocks's avatar alexstocks

add remark

parent 567fa0c4
...@@ -11,6 +11,11 @@ ...@@ -11,6 +11,11 @@
## develop history ## ## develop history ##
--- ---
- 2016/09/18
> 1 close Session{rQ} in session.go:(Session)handlePackage
>
> 2 version: 0.3.09
- 2016/09/12 - 2016/09/12
> 1 add defeat self connection logic in client.go & server.go > 1 add defeat self connection logic in client.go & server.go
> >
......
...@@ -354,8 +354,9 @@ func (this *Session) RunEventLoop() { ...@@ -354,8 +354,9 @@ func (this *Session) RunEventLoop() {
func (this *Session) handleLoop() { func (this *Session) handleLoop() {
var ( var (
err error err error
flag bool flag bool
rQFlag bool
// start time.Time // start time.Time
counter CountWatch counter CountWatch
ticker *time.Ticker ticker *time.Ticker
...@@ -401,13 +402,15 @@ LOOP: ...@@ -401,13 +402,15 @@ LOOP:
} }
} }
case inPkg = <-this.rQ: case inPkg, rQFlag = <-this.rQ:
// 这个条件分支通过(Session)rQ排空确保(Session)handlePackage gr不会阻塞在(Session)rQ上 // 这个条件分支通过(Session)rQ排空确保(Session)handlePackage gr不会阻塞在(Session)rQ上
if flag { if rQFlag {
this.listener.OnMessage(this, inPkg) if flag {
this.incReadPkgCount() this.listener.OnMessage(this, inPkg)
} else { this.incReadPkgCount()
log.Info("[session.handleLoop] drop readin package{%#v}", inPkg) } else {
log.Info("[session.handleLoop] drop readin package{%#v}", inPkg)
}
} }
case outPkg = <-this.wQ: case outPkg = <-this.wQ:
...@@ -459,11 +462,12 @@ func (this *Session) handlePackage() { ...@@ -459,11 +462,12 @@ func (this *Session) handlePackage() {
} }
this.stop() this.stop()
close(this.rQ)
// close(this.readerDone) // close(this.readerDone)
grNum = atomic.AddInt32(&(this.grNum), -1) grNum = atomic.AddInt32(&(this.grNum), -1)
log.Info("%s, [session.handlePackage] gr will exit now, left gr num %d", this.sessionToken(), grNum) log.Info("%s, [session.handlePackage] gr will exit now, left gr num %d", this.sessionToken(), grNum)
if errFlag { if errFlag {
log.Info("%s, [session.handlePackage] errFlag", this.sessionToken()) log.Error("%s, [session.handlePackage] error{%#v}", this.sessionToken(), err)
this.listener.OnError(this, err) this.listener.OnError(this, err)
} }
}() }()
...@@ -524,7 +528,7 @@ func (this *Session) handlePackage() { ...@@ -524,7 +528,7 @@ func (this *Session) handlePackage() {
func (this *Session) stop() { func (this *Session) stop() {
select { select {
case <-this.done: case <-this.done: // this.done is a blocked channel. if it has not been closed, the default branch will be invoked.
return return
default: default:
...@@ -543,7 +547,7 @@ func (this *Session) gc() { ...@@ -543,7 +547,7 @@ func (this *Session) gc() {
// } // }
close(this.wQ) close(this.wQ)
this.wQ = nil this.wQ = nil
close(this.rQ) // close(this.rQ)
this.rQ = nil this.rQ = nil
this.gettyConn.close((int)((int64)(this.wait))) this.gettyConn.close((int)((int64)(this.wait)))
} }
...@@ -554,6 +558,5 @@ func (this *Session) gc() { ...@@ -554,6 +558,5 @@ func (this *Session) gc() {
// It is goroutine-safe to be invoked many times. // It is goroutine-safe to be invoked many times.
func (this *Session) Close() { func (this *Session) Close() {
this.stop() this.stop()
log.Info("%s closed now, its current gr num %d", log.Info("%s closed now, its current gr num %d", this.sessionToken(), atomic.LoadInt32(&(this.grNum)))
this.sessionToken(), atomic.LoadInt32(&(this.grNum)))
} }
...@@ -10,5 +10,5 @@ ...@@ -10,5 +10,5 @@
package getty package getty
var ( var (
Version = "0.3.08" Version = "0.3.09"
) )
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