Merge pull request #293 from filecoin-project/fix/websocket-closing-2

fix websocket closing again
This commit is contained in:
Łukasz Magiera 2019-10-08 10:34:44 +02:00 committed by GitHub
commit 49e8b5d334
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 0 deletions

View File

@ -88,6 +88,7 @@ func NewMergeClient(addr string, namespace string, outs []interface{}, requestHe
}
stop := make(chan struct{})
exiting := make(chan struct{})
c.requests = make(chan clientRequest)
handlers := map[string]rpcHandler{}
@ -96,6 +97,7 @@ func NewMergeClient(addr string, namespace string, outs []interface{}, requestHe
handler: handlers,
requests: c.requests,
stop: stop,
exiting: exiting,
}).handleWsConn(context.TODO())
for _, handler := range outs {
@ -122,6 +124,7 @@ func NewMergeClient(addr string, namespace string, outs []interface{}, requestHe
return func() {
close(stop)
<-exiting
}, nil
}

View File

@ -52,6 +52,7 @@ func (s *RPCServer) handleWS(ctx context.Context, w http.ResponseWriter, r *http
(&wsConn{
conn: c,
handler: s.methods,
exiting: make(chan struct{}),
}).handleWsConn(ctx)
if err := c.Close(); err != nil {

View File

@ -43,6 +43,7 @@ type wsConn struct {
handler handlers
requests <-chan clientRequest
stop <-chan struct{}
exiting chan struct{}
// incoming messages
incoming chan io.Reader
@ -389,6 +390,7 @@ func (c *wsConn) handleWsConn(ctx context.Context) {
c.registerCh = make(chan outChanReg)
defer close(c.registerCh)
defer close(c.exiting)
// ////