Commit 59ebcbc1 authored by alexstocks's avatar alexstocks

add once for done

parent 89139c56
......@@ -15,6 +15,7 @@
- 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()
> add once for session.go:Session:done(chan struct{})
> version: 0.2.05
- 2016/08/23
......
......@@ -84,6 +84,7 @@ type Session struct {
*gettyConn
pkgHandler ReadWriter
listener EventListener
once sync.Once
done chan struct{}
readerDone chan struct{} // end reader
......@@ -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