Commit a3aa7838 authored by alexstocks's avatar alexstocks

modify write timeout and wheel time interval

parent 61d671ba
...@@ -11,6 +11,13 @@ ...@@ -11,6 +11,13 @@
## develop history ## ## develop history ##
--- ---
- 2016/09/30
> 1 modify wheel time interval from 1 second to 100ms.
>
> 2 modify session.go:(Session)WritePkg timeout
>
> 2 version: 0.3.13
- 2016/09/27 - 2016/09/27
> 1 fix bug: getty panic when conn.RemoteAddr() is nil in session.go:(Session)sessionToken() > 1 fix bug: getty panic when conn.RemoteAddr() is nil in session.go:(Session)sessionToken()
> >
......
...@@ -44,7 +44,7 @@ var ( ...@@ -44,7 +44,7 @@ var (
var ( var (
connID uint32 connID uint32
wheel *gxtime.Wheel = gxtime.NewWheel(gxtime.TimeSecondDuration(1), 3600) // wheel longest span is 1 hour wheel = gxtime.NewWheel(gxtime.TimeMillisecondDuration(100), 6000) // wheel longest span is 10minute
) )
type gettyConn struct { type gettyConn struct {
...@@ -326,6 +326,10 @@ func (this *Session) WritePkg(pkg interface{}) error { ...@@ -326,6 +326,10 @@ func (this *Session) WritePkg(pkg interface{}) error {
} }
}() }()
var d = this.wDeadline
if d > netIOTimeout {
d = netIOTimeout
}
select { select {
case this.wQ <- pkg: case this.wQ <- pkg:
break // for possible gen a new pkg break // for possible gen a new pkg
...@@ -333,7 +337,7 @@ func (this *Session) WritePkg(pkg interface{}) error { ...@@ -333,7 +337,7 @@ func (this *Session) WritePkg(pkg interface{}) error {
// default: // default:
// case <-time.After(this.wDeadline): // case <-time.After(this.wDeadline):
// case <-time.After(netIOTimeout): // case <-time.After(netIOTimeout):
case <-wheel.After(this.wDeadline): case <-wheel.After(d):
log.Warn("%s, [session.WritePkg] wQ{len:%d, cap:%d}", this.Stat(), len(this.wQ), cap(this.wQ)) log.Warn("%s, [session.WritePkg] wQ{len:%d, cap:%d}", this.Stat(), len(this.wQ), cap(this.wQ))
return ErrSessionBlocked return ErrSessionBlocked
} }
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
package getty package getty
const ( const (
Version = "0.3.12" Version = "0.3.13"
GETTY_MAJOR = 0 GETTY_MAJOR = 0
GETTY_MINOR = 3 GETTY_MINOR = 3
GETTY_BUILD = 12 GETTY_BUILD = 13
) )
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