Commit 59ebcbc1 authored by alexstocks's avatar alexstocks

add once for done

parent 89139c56
......@@ -4,41 +4,42 @@
## introdction ##
---
> DESC : a asynchronous network I/O library in golang
LICENCE : Apache License 2.0
AUTHOR : https://github.com/sanbit
MAINTAINER : Alex Stocks
> DESC : a asynchronous network I/O library in golang
LICENCE : Apache License 2.0
AUTHOR : https://github.com/sanbit
MAINTAINER : Alex Stocks
EMAIL : alexstocks@foxmail.com
## develop history ##
---
- 2016/08/24
> delete session.go:Session:wg(atomic.WaitGroup). Add session.go:Session:grNum instead to prevent from (Session)Close() block on session.go:Session:wg.Wait()
> version: 0.2.05
> delete session.go:Session:wg(atomic.WaitGroup). Add session.go:Session:grNum instead to prevent from (Session)Close() block on session.go:Session:wg.Wait()
> add once for session.go:Session:done(chan struct{})
> version: 0.2.05
- 2016/08/23
> do not consider empty package as a error in (Session)handlePackage
> version: 0.2.04
> do not consider empty package as a error in (Session)handlePackage
> version: 0.2.04
- 2016/08/22
> rename (Session)OnIdle to (Session)OnCron
> rewrite server.go: add Server{done, wg}
> add utils.go
> version: 0.2.03
> rename (Session)OnIdle to (Session)OnCron
> rewrite server.go: add Server{done, wg}
> add utils.go
> version: 0.2.03
- 2016/08/21
> add name for Session
> add OnError for Codec
> add name for Session
> add OnError for Codec
- 2016/08/18
> delete last clause of handleRead
> add reqQ handle case in last clause of handleLoop
> add conditon check in (*Session)RunEventLoop()
> version: 0.2.02
> delete last clause of handleRead
> add reqQ handle case in last clause of handleLoop
> add conditon check in (*Session)RunEventLoop()
> version: 0.2.02
- 2016/08/16
> rename all structs
> add getty connection
> rewrite (Session)handleRead & (Session)handleEventLoop
> version: 0.2.01
> rename all structs
> add getty connection
> rewrite (Session)handleRead & (Session)handleEventLoop
> version: 0.2.01
......@@ -84,6 +84,7 @@ type Session struct {
*gettyConn
pkgHandler ReadWriter
listener EventListener
once sync.Once
done chan struct{}
readerDone chan struct{} // end reader
......@@ -98,7 +99,7 @@ type Session struct {
attrs map[string]interface{}
// goroutines sync
grNum int32
lock sync.RWMutex
lock sync.RWMutex
}
func NewSession(conn net.Conn) *Session {
......@@ -239,7 +240,8 @@ func (this *Session) stop() {
case <-this.done:
return
default:
close(this.done)
// defeat "panic: close of closed channel"
this.once.Do(func() { close(this.done) })
}
}
......
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