use mutex instead of rwmutex

This commit is contained in:
Nan Deng 2014-06-30 11:13:42 -07:00
parent 3083a33e5f
commit f99a50ba69

View File

@ -27,7 +27,7 @@ type MockPodRegistry struct {
err error
pod *api.Pod
pods []api.Pod
sync.RWMutex
sync.Mutex
}
func MakeMockPodRegistry(pods []api.Pod) *MockPodRegistry {
@ -37,8 +37,8 @@ func MakeMockPodRegistry(pods []api.Pod) *MockPodRegistry {
}
func (registry *MockPodRegistry) ListPods(selector labels.Selector) ([]api.Pod, error) {
registry.RLock()
defer registry.RUnlock()
registry.Lock()
defer registry.Unlock()
if registry.err != nil {
return registry.pods, registry.err
}
@ -52,24 +52,24 @@ func (registry *MockPodRegistry) ListPods(selector labels.Selector) ([]api.Pod,
}
func (registry *MockPodRegistry) GetPod(podId string) (*api.Pod, error) {
registry.RLock()
defer registry.RUnlock()
registry.Lock()
defer registry.Unlock()
return registry.pod, registry.err
}
func (registry *MockPodRegistry) CreatePod(machine string, pod api.Pod) error {
registry.RLock()
defer registry.RUnlock()
registry.Lock()
defer registry.Unlock()
return registry.err
}
func (registry *MockPodRegistry) UpdatePod(pod api.Pod) error {
registry.RLock()
defer registry.RUnlock()
registry.Lock()
defer registry.Unlock()
return registry.err
}
func (registry *MockPodRegistry) DeletePod(podId string) error {
registry.RLock()
defer registry.RUnlock()
registry.Lock()
defer registry.Unlock()
return registry.err
}