rpcenc: Propagate closeOnce in beginPost

This commit is contained in:
Łukasz Magiera 2023-03-07 16:48:33 +01:00
parent f2a652f29f
commit ec5fde466a
2 changed files with 3 additions and 3 deletions

View File

@ -221,7 +221,7 @@ type RpcReader struct {
res chan readRes res chan readRes
beginOnce *sync.Once beginOnce *sync.Once
closeOnce sync.Once closeOnce *sync.Once
} }
var ErrHasBody = errors.New("RPCReader has body, either already read from or from a client with no redirect support") var ErrHasBody = errors.New("RPCReader has body, either already read from or from a client with no redirect support")
@ -265,6 +265,7 @@ func (w *RpcReader) beginPost() {
w.postBody = nr.postBody w.postBody = nr.postBody
w.res = nr.res w.res = nr.res
w.beginOnce = nr.beginOnce w.beginOnce = nr.beginOnce
w.closeOnce = nr.closeOnce
} }
} }
@ -355,6 +356,7 @@ func ReaderParamDecoder() (http.HandlerFunc, jsonrpc.ServerOption) {
res: make(chan readRes), res: make(chan readRes),
next: ch, next: ch,
beginOnce: &sync.Once{}, beginOnce: &sync.Once{},
closeOnce: &sync.Once{},
} }
switch req.Method { switch req.Method {

View File

@ -326,8 +326,6 @@ func testReaderRedirectDrop(t *testing.T) {
// kill redirecting server connection // kill redirecting server connection
testServ.CloseClientConnections() testServ.CloseClientConnections()
//time.Sleep(200 * time.Millisecond)
// ReadAllWaiting should fail // ReadAllWaiting should fail
done.Wait() done.Wait()