Commit 8ed4cde0 authored by Geoff Simmons's avatar Geoff Simmons

Fix nil checks for vsm.Attach*() methods.

parent 98969dd6
......@@ -143,6 +143,15 @@ func TestAttachInstance(t *testing.T) {
t.Error("expected AttachInstance() to fail for a " +
"non-existent instance")
}
var n *VSM
if err := n.AttachInstance("gotest", false); err == nil {
t.Error("expected nil.AttachInstance() to fail")
}
uninit := new(VSM)
if err := uninit.AttachInstance("gotest", false); err == nil {
t.Error("expected uninitialized.AttachInstance() to fail")
}
}
func TestPointer(t *testing.T) {
......
......@@ -139,9 +139,6 @@ func (v *VSM) AttachTmo(tmo time.Duration) error {
}
func (v *VSM) attach(progress bool) error {
if err := v.checkNil(); err != nil {
return err
}
prog := -1
if progress {
prog = 0
......@@ -156,12 +153,18 @@ func (v *VSM) attach(progress bool) error {
// Attach attaches to the default instance of Varnish, as documented
// for the Attacher interface.
func (v *VSM) Attach(progress bool) error {
if err := v.checkNil(); err != nil {
return err
}
return v.attach(progress)
}
// AttachInstance attaches to a named instance of Varnish, as
// documented for the Attacher interface.
func (v *VSM) AttachInstance(inst string, progress bool) error {
if err := v.checkNil(); err != nil {
return err
}
C.VSM_ResetError(v.vsm)
if C.VSM_Arg(v.vsm, 'n', C.CString(inst)) != 1 {
return v
......
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