Przeglądaj źródła

etcdserver/api/rafthttp: fix the location of close http body.

johncming 7 lat temu
rodzic
commit
bd41f74168
1 zmienionych plików z 1 dodań i 1 usunięć
  1. 1 1
      etcdserver/api/rafthttp/pipeline.go

+ 1 - 1
etcdserver/api/rafthttp/pipeline.go

@@ -155,12 +155,12 @@ func (p *pipeline) post(data []byte) (err error) {
 		p.picker.unreachable(u)
 		return err
 	}
+	defer resp.Body.Close()
 	b, err := ioutil.ReadAll(resp.Body)
 	if err != nil {
 		p.picker.unreachable(u)
 		return err
 	}
-	resp.Body.Close()
 
 	err = checkPostResponse(resp, b, req, p.peerID)
 	if err != nil {