fix websocket closing again
This commit is contained in:
parent
cefd75be64
commit
86deb7528c
@ -88,6 +88,7 @@ func NewMergeClient(addr string, namespace string, outs []interface{}, requestHe
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop := make(chan struct{})
|
stop := make(chan struct{})
|
||||||
|
exiting := make(chan struct{})
|
||||||
c.requests = make(chan clientRequest)
|
c.requests = make(chan clientRequest)
|
||||||
|
|
||||||
handlers := map[string]rpcHandler{}
|
handlers := map[string]rpcHandler{}
|
||||||
@ -96,6 +97,7 @@ func NewMergeClient(addr string, namespace string, outs []interface{}, requestHe
|
|||||||
handler: handlers,
|
handler: handlers,
|
||||||
requests: c.requests,
|
requests: c.requests,
|
||||||
stop: stop,
|
stop: stop,
|
||||||
|
exiting: exiting,
|
||||||
}).handleWsConn(context.TODO())
|
}).handleWsConn(context.TODO())
|
||||||
|
|
||||||
for _, handler := range outs {
|
for _, handler := range outs {
|
||||||
@ -122,6 +124,7 @@ func NewMergeClient(addr string, namespace string, outs []interface{}, requestHe
|
|||||||
|
|
||||||
return func() {
|
return func() {
|
||||||
close(stop)
|
close(stop)
|
||||||
|
<-exiting
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ func (s *RPCServer) handleWS(ctx context.Context, w http.ResponseWriter, r *http
|
|||||||
(&wsConn{
|
(&wsConn{
|
||||||
conn: c,
|
conn: c,
|
||||||
handler: s.methods,
|
handler: s.methods,
|
||||||
|
exiting: make(chan struct{}),
|
||||||
}).handleWsConn(ctx)
|
}).handleWsConn(ctx)
|
||||||
|
|
||||||
if err := c.Close(); err != nil {
|
if err := c.Close(); err != nil {
|
||||||
|
@ -43,6 +43,7 @@ type wsConn struct {
|
|||||||
handler handlers
|
handler handlers
|
||||||
requests <-chan clientRequest
|
requests <-chan clientRequest
|
||||||
stop <-chan struct{}
|
stop <-chan struct{}
|
||||||
|
exiting chan struct{}
|
||||||
|
|
||||||
// incoming messages
|
// incoming messages
|
||||||
incoming chan io.Reader
|
incoming chan io.Reader
|
||||||
@ -389,6 +390,7 @@ func (c *wsConn) handleWsConn(ctx context.Context) {
|
|||||||
|
|
||||||
c.registerCh = make(chan outChanReg)
|
c.registerCh = make(chan outChanReg)
|
||||||
defer close(c.registerCh)
|
defer close(c.registerCh)
|
||||||
|
defer close(c.exiting)
|
||||||
|
|
||||||
// ////
|
// ////
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user