|
|
|
|
@ -2,6 +2,7 @@ package rpc
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/mitchellh/packer/packer"
|
|
|
|
|
"log"
|
|
|
|
|
"net/rpc"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@ -24,7 +25,8 @@ type CacheRLockResponse struct {
|
|
|
|
|
|
|
|
|
|
func (c *cache) Lock(key string) (result string) {
|
|
|
|
|
if err := c.client.Call("Cache.Lock", key, &result); err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
log.Printf("[ERR] Cache.Lock error: %s", err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
@ -33,7 +35,8 @@ func (c *cache) Lock(key string) (result string) {
|
|
|
|
|
func (c *cache) RLock(key string) (string, bool) {
|
|
|
|
|
var result CacheRLockResponse
|
|
|
|
|
if err := c.client.Call("Cache.RLock", key, &result); err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
log.Printf("[ERR] Cache.RLock error: %s", err)
|
|
|
|
|
return "", false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result.Path, result.Exists
|
|
|
|
|
@ -41,13 +44,15 @@ func (c *cache) RLock(key string) (string, bool) {
|
|
|
|
|
|
|
|
|
|
func (c *cache) Unlock(key string) {
|
|
|
|
|
if err := c.client.Call("Cache.Unlock", key, new(interface{})); err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
log.Printf("[ERR] Cache.Unlock error: %s", err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *cache) RUnlock(key string) {
|
|
|
|
|
if err := c.client.Call("Cache.RUnlock", key, new(interface{})); err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
log.Printf("[ERR] Cache.RUnlock error: %s", err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|