client: move lock so MembersAPI.List doesn't deadlock

This commit is contained in:
Brian Waldon 2015-01-29 16:12:34 -08:00 committed by Yicheng Qin
parent 83930ac113
commit ae062a0825

View File

@ -223,15 +223,15 @@ func (c *httpClusterClient) Endpoints() []string {
}
func (c *httpClusterClient) Sync(ctx context.Context) error {
c.Lock()
defer c.Unlock()
mAPI := NewMembersAPI(c)
ms, err := mAPI.List(ctx)
if err != nil {
return err
}
c.Lock()
defer c.Unlock()
eps := make([]string, 0)
for _, m := range ms {
eps = append(eps, m.ClientURLs...)