summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzheng <Zheng.chai@citrix.com>2016-04-25 11:19:40 +0800
committerzheng <Zheng.chai@citrix.com>2016-04-25 11:19:40 +0800
commit0db9ba6f51eac2be8d1fbd4e2d6801f4a47f97b5 (patch)
tree192af78bc84a96eb3b9f5ae4b8b43df682636217
parentaad6f64ca833cc556d65de2c8968ad29c50931a4 (diff)
parent5c06998aee96aa02fddf1f6d3122ad1badbafd55 (diff)
downloadvyos-xe-guest-utilities-0db9ba6f51eac2be8d1fbd4e2d6801f4a47f97b5.tar.gz
vyos-xe-guest-utilities-0db9ba6f51eac2be8d1fbd4e2d6801f4a47f97b5.zip
Merge pull request #12 from jjd27/master
Make xe-daemon generate less xenstore traffic
-rw-r--r--xenstoreclient/xenstore.go11
1 files changed, 2 insertions, 9 deletions
diff --git a/xenstoreclient/xenstore.go b/xenstoreclient/xenstore.go
index cc30828..7b61670 100644
--- a/xenstoreclient/xenstore.go
+++ b/xenstoreclient/xenstore.go
@@ -13,7 +13,6 @@ import (
"strconv"
"strings"
"sync"
- "time"
)
type Permission int
@@ -464,7 +463,6 @@ func (xs *XenStore) StopWatch() error {
type CachedXenStore struct {
xs XenStoreClient
writeCache map[string]string
- lastCommit map[string]time.Time
}
func NewCachedXenstore(tx uint32) (XenStoreClient, error) {
@@ -475,20 +473,16 @@ func NewCachedXenstore(tx uint32) (XenStoreClient, error) {
return &CachedXenStore{
xs: xs,
writeCache: make(map[string]string, 0),
- lastCommit: make(map[string]time.Time, 0),
}, nil
}
func (xs *CachedXenStore) Write(path string, value string) error {
if v, ok := xs.writeCache[path]; ok && v == value {
- if t, ok := xs.lastCommit[path]; ok && t.After(time.Now().Add(-2*time.Minute)) {
- return nil
- }
+ return nil
}
err := xs.xs.Write(path, value)
- if err != nil {
+ if err == nil {
xs.writeCache[path] = value
- xs.lastCommit[path] = time.Now()
}
return err
}
@@ -535,7 +529,6 @@ func (xs *CachedXenStore) StopWatch() error {
func (xs *CachedXenStore) Clear() {
xs.writeCache = make(map[string]string, 0)
- xs.lastCommit = make(map[string]time.Time, 0)
}
func getDevPath() (devPath string, err error) {