| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package dscache | 5 package dscache |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "math/rand" | 9 "math/rand" |
| 10 "time" | 10 "time" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 110 } |
| 111 if err := s.mc.SetMulti(lockItems); err != nil { | 111 if err := s.mc.SetMulti(lockItems); err != nil { |
| 112 // this is a hard failure. No mutation can occur if we're unable
to set | 112 // this is a hard failure. No mutation can occur if we're unable
to set |
| 113 // locks out. See "DANGER ZONE" in the docs. | 113 // locks out. See "DANGER ZONE" in the docs. |
| 114 (log.Fields{log.ErrorKey: err}).Errorf( | 114 (log.Fields{log.ErrorKey: err}).Errorf( |
| 115 s.c, "dscache: HARD FAILURE: supportContext.mutation():
mc.SetMulti") | 115 s.c, "dscache: HARD FAILURE: supportContext.mutation():
mc.SetMulti") |
| 116 return err | 116 return err |
| 117 } | 117 } |
| 118 err := f() | 118 err := f() |
| 119 if err == nil { | 119 if err == nil { |
| 120 » » if err := s.mc.DeleteMulti(lockKeys); err != nil { | 120 » » if err := filterMCErr(s.mc.DeleteMulti(lockKeys)); err != nil { |
| 121 (log.Fields{log.ErrorKey: err}).Warningf( | 121 (log.Fields{log.ErrorKey: err}).Warningf( |
| 122 s.c, "dscache: mc.DeleteMulti") | 122 s.c, "dscache: mc.DeleteMulti") |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 return err | 125 return err |
| 126 } | 126 } |
| 127 | 127 |
| 128 func (s *supportContext) mkRandLockItems(keys []*ds.Key, metas ds.MultiMetaGette
r) ([]memcache.Item, []byte) { | 128 func (s *supportContext) mkRandLockItems(keys []*ds.Key, metas ds.MultiMetaGette
r) ([]memcache.Item, []byte) { |
| 129 mcKeys := s.mkRandKeys(keys, metas) | 129 mcKeys := s.mkRandKeys(keys, metas) |
| 130 if len(mcKeys) == 0 { | 130 if len(mcKeys) == 0 { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 150 return nil, nil | 150 return nil, nil |
| 151 } | 151 } |
| 152 ret := make([]memcache.Item, len(mcKeys)) | 152 ret := make([]memcache.Item, len(mcKeys)) |
| 153 for i := range ret { | 153 for i := range ret { |
| 154 ret[i] = (s.mc.NewItem(mcKeys[i]). | 154 ret[i] = (s.mc.NewItem(mcKeys[i]). |
| 155 SetFlags(uint32(ItemHasLock)). | 155 SetFlags(uint32(ItemHasLock)). |
| 156 SetExpiration(time.Second * time.Duration(LockTimeSecond
s))) | 156 SetExpiration(time.Second * time.Duration(LockTimeSecond
s))) |
| 157 } | 157 } |
| 158 return ret, mcKeys | 158 return ret, mcKeys |
| 159 } | 159 } |
| OLD | NEW |