diff --git a/http.go b/http.go index 0531a80..bd716a0 100644 --- a/http.go +++ b/http.go @@ -41,7 +41,7 @@ type httpClient struct { funcStream client.FuncStream httpcli *http.Client opts client.Options - sync.RWMutex + mu sync.RWMutex } func newRequest(ctx context.Context, log logger.Logger, addr string, req client.Request, ct string, cf codec.Codec, msg interface{}, opts client.CallOptions) (*http.Request, error) { @@ -294,18 +294,18 @@ func (c *httpClient) stream(ctx context.Context, addr string, req client.Request } func (c *httpClient) newCodec(ct string) (codec.Codec, error) { - c.RLock() + c.mu.RLock() if idx := strings.IndexRune(ct, ';'); idx >= 0 { ct = ct[:idx] } if cf, ok := c.opts.Codecs[ct]; ok { - c.RUnlock() + c.mu.RUnlock() return cf, nil } - c.RUnlock() + c.mu.RUnlock() return nil, codec.ErrUnknownContentType } diff --git a/stream.go b/stream.go index 9f30103..d5b765c 100644 --- a/stream.go +++ b/stream.go @@ -28,7 +28,7 @@ type httpStream struct { address string ct string opts client.CallOptions - sync.RWMutex + mu sync.RWMutex } var errShutdown = fmt.Errorf("connection is shut down") @@ -59,8 +59,8 @@ func (h *httpStream) SendMsg(msg interface{}) error { } func (h *httpStream) Send(msg interface{}) error { - h.Lock() - defer h.Unlock() + h.mu.Lock() + defer h.mu.Unlock() if h.isClosed() { h.err = errShutdown @@ -80,8 +80,8 @@ func (h *httpStream) RecvMsg(msg interface{}) error { } func (h *httpStream) Recv(msg interface{}) error { - h.Lock() - defer h.Unlock() + h.mu.Lock() + defer h.mu.Unlock() if h.isClosed() { h.err = errShutdown @@ -98,8 +98,8 @@ func (h *httpStream) Recv(msg interface{}) error { } func (h *httpStream) Error() error { - h.RLock() - defer h.RUnlock() + h.mu.RLock() + defer h.mu.RUnlock() return h.err }