From 6ec32805d013ec219796b2c5c25186372b0b20c1 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Tue, 10 Sep 2019 18:26:12 -0700 Subject: [PATCH] Don't allow socket close while writing h2 headers --- transport/http_transport.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/transport/http_transport.go b/transport/http_transport.go index e6fd1b05..c9878073 100644 --- a/transport/http_transport.go +++ b/transport/http_transport.go @@ -316,6 +316,10 @@ func (h *httpTransportSocket) Send(m *Message) error { // no op } + // we need to lock to protect the write + h.mtx.RLock() + defer h.mtx.RUnlock() + // set headers for k, v := range m.Header { h.w.Header().Set(k, v)