mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcd: fix data race in transporter
This commit is contained in:
parent
3f435571d3
commit
284e76f0da
@ -87,11 +87,11 @@ func (t *transporter) send(addr string, data []byte) error {
|
||||
t.mu.RUnlock()
|
||||
return fmt.Errorf("transporter stopped")
|
||||
}
|
||||
t.wg.Add(1)
|
||||
defer t.wg.Done()
|
||||
t.mu.RUnlock()
|
||||
|
||||
buf := bytes.NewBuffer(data)
|
||||
t.wg.Add(1)
|
||||
defer t.wg.Done()
|
||||
resp, err := t.client.Post(addr, "application/octet-stream", buf)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -148,7 +148,10 @@ func (t *transporter) serveCfg(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if u, ok := t.urls[id]; ok {
|
||||
t.mu.RLock()
|
||||
u, ok := t.urls[id]
|
||||
t.mu.RUnlock()
|
||||
if ok {
|
||||
w.Write([]byte(u))
|
||||
return
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user