Skip to content
Permalink
Browse files
Fix: delete Empty
  • Loading branch information
AlexStocks committed Nov 21, 2018
1 parent 6a7f8a3 commit f108db1d33507366a072d6c730340657ae54c4f6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
@@ -23,7 +23,6 @@ import (

import (
"github.com/AlexStocks/goext/net"
"github.com/AlexStocks/goext/sync"
log "github.com/AlexStocks/log4go"
"github.com/gorilla/websocket"
jerrors "github.com/juju/errors"
@@ -52,10 +51,10 @@ type client struct {
endPointType EndPointType

newSession NewSessionCallback
ssMap map[Session]gxsync.Empty
ssMap map[Session]struct{}

sync.Once
done chan gxsync.Empty
done chan struct{}
wg sync.WaitGroup
}

@@ -68,7 +67,7 @@ func (c *client) init(opts ...ClientOption) {
func newClient(t EndPointType, opts ...ClientOption) *client {
c := &client{
endPointType: t,
done: make(chan gxsync.Empty),
done: make(chan struct{}),
}

c.init(opts...)
@@ -77,7 +76,7 @@ func newClient(t EndPointType, opts ...ClientOption) *client {
panic(fmt.Sprintf("client type:%s, @connNum:%d, @serverAddr:%s", t, c.number, c.addr))
}

c.ssMap = make(map[Session]gxsync.Empty, c.number)
c.ssMap = make(map[Session]struct{}, c.number)

return c
}
@@ -362,7 +361,7 @@ func (c *client) connect() {
// ss.RunEventLoop()
ss.(*session).run()
c.Lock()
c.ssMap[ss] = gxsync.Empty{}
c.ssMap[ss] = struct{}{}
c.Unlock()
ss.SetAttribute(sessionClientKey, c)
break
@@ -14,7 +14,7 @@ import (
)

var (
errTooManySessions = jerrors.New("too many echo sessions")
errTooManySessions = jerrors.New("too many sessions")
)

type rpcSession struct {
@@ -44,7 +44,7 @@ func NewRpcServerHandler(maxSessionNum int, sessionTimeout time.Duration) *RpcSe
func (h *RpcServerHandler) OnOpen(session getty.Session) error {
var err error
h.rwlock.RLock()
if h.maxSessionNum < len(h.sessionMap) {
if h.maxSessionNum <= len(h.sessionMap) {
err = errTooManySessions
}
h.rwlock.RUnlock()
@@ -23,7 +23,6 @@ import (

import (
"github.com/AlexStocks/goext/net"
"github.com/AlexStocks/goext/sync"
"github.com/AlexStocks/goext/time"
log "github.com/AlexStocks/log4go"
"github.com/gorilla/websocket"
@@ -46,7 +45,7 @@ type server struct {
server *http.Server // for ws or wss server

sync.Once
done chan gxsync.Empty
done chan struct{}
wg sync.WaitGroup
}

@@ -59,7 +58,7 @@ func (s *server) init(opts ...ServerOption) {
func newServer(t EndPointType, opts ...ServerOption) *server {
s := &server{
endPointType: t,
done: make(chan gxsync.Empty),
done: make(chan struct{}),
}

s.init(opts...)
@@ -27,7 +27,6 @@ import (

import (
"github.com/AlexStocks/goext/context"
"github.com/AlexStocks/goext/sync"
"github.com/AlexStocks/goext/time"
)

@@ -68,7 +67,7 @@ type session struct {
writer Writer
listener EventListener
once sync.Once
done chan gxsync.Empty
done chan struct{}
// errFlag bool

period time.Duration
@@ -89,7 +88,7 @@ func newSession(endPoint EndPoint, conn Connection) *session {
endPoint: endPoint,
maxMsgLen: maxReadBufLen,
Connection: conn,
done: make(chan gxsync.Empty),
done: make(chan struct{}),
period: period,
wait: pendingDuration,
attrs: gxcontext.NewValuesContext(nil),
@@ -129,7 +128,7 @@ func newWSSession(conn *websocket.Conn, endPoint EndPoint) Session {
func (s *session) Reset() {
s.name = defaultSessionName
s.once = sync.Once{}
s.done = make(chan gxsync.Empty)
s.done = make(chan struct{})
// s.errFlag = false
s.period = period
s.wait = pendingDuration

0 comments on commit f108db1

Please sign in to comment.