Browse Source

api/v2auth: remove defer in loop.

caoming 7 years ago
parent
commit
e96dbfb973
1 changed files with 1 additions and 1 deletions
  1. 1 1
      etcdserver/api/v2auth/auth_requests.go

+ 1 - 1
etcdserver/api/v2auth/auth_requests.go

@@ -32,7 +32,6 @@ func (s *store) ensureAuthDirectories() error {
 	}
 	for _, res := range []string{StorePermsPrefix, StorePermsPrefix + "/users/", StorePermsPrefix + "/roles/"} {
 		ctx, cancel := context.WithTimeout(context.Background(), s.timeout)
-		defer cancel()
 		pe := false
 		rr := etcdserverpb.Request{
 			Method:    "PUT",
@@ -41,6 +40,7 @@ func (s *store) ensureAuthDirectories() error {
 			PrevExist: &pe,
 		}
 		_, err := s.server.Do(ctx, rr)
+		cancel()
 		if err != nil {
 			if e, ok := err.(*v2error.Error); ok {
 				if e.ErrorCode == v2error.EcodeNodeExist {