Commit ad51098a authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

packer/rpc: don't panic on cache errors [GH-1328]

parent e9c2628a
...@@ -22,6 +22,7 @@ BUG FIXES: ...@@ -22,6 +22,7 @@ BUG FIXES:
* core: nicer error message if an encrypted private key is used for * core: nicer error message if an encrypted private key is used for
SSH. [GH-1445] SSH. [GH-1445]
* core: Fix crash that could happen with a well timed double Ctrl-C. [GH-1328]
* builder/amazon-chroot: Can properly build HVM images now. [GH-1360] * builder/amazon-chroot: Can properly build HVM images now. [GH-1360]
* builder/amazon-chroot: Fix crash in root device check. [GH-1360] * builder/amazon-chroot: Fix crash in root device check. [GH-1360]
* builder/amazon-instance: Fix deprecation warning for `ec2-bundle-vol` * builder/amazon-instance: Fix deprecation warning for `ec2-bundle-vol`
......
...@@ -2,6 +2,7 @@ package rpc ...@@ -2,6 +2,7 @@ package rpc
import ( import (
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"log"
"net/rpc" "net/rpc"
) )
...@@ -24,7 +25,8 @@ type CacheRLockResponse struct { ...@@ -24,7 +25,8 @@ type CacheRLockResponse struct {
func (c *cache) Lock(key string) (result string) { func (c *cache) Lock(key string) (result string) {
if err := c.client.Call("Cache.Lock", key, &result); err != nil { if err := c.client.Call("Cache.Lock", key, &result); err != nil {
panic(err) log.Printf("[ERR] Cache.Lock error: %s", err)
return
} }
return return
...@@ -33,7 +35,8 @@ func (c *cache) Lock(key string) (result string) { ...@@ -33,7 +35,8 @@ func (c *cache) Lock(key string) (result string) {
func (c *cache) RLock(key string) (string, bool) { func (c *cache) RLock(key string) (string, bool) {
var result CacheRLockResponse var result CacheRLockResponse
if err := c.client.Call("Cache.RLock", key, &result); err != nil { 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 return result.Path, result.Exists
...@@ -41,13 +44,15 @@ func (c *cache) RLock(key string) (string, bool) { ...@@ -41,13 +44,15 @@ func (c *cache) RLock(key string) (string, bool) {
func (c *cache) Unlock(key string) { func (c *cache) Unlock(key string) {
if err := c.client.Call("Cache.Unlock", key, new(interface{})); err != nil { 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) { func (c *cache) RUnlock(key string) {
if err := c.client.Call("Cache.RUnlock", key, new(interface{})); err != nil { if err := c.client.Call("Cache.RUnlock", key, new(interface{})); err != nil {
panic(err) log.Printf("[ERR] Cache.RUnlock error: %s", err)
return
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment