From 4bd757cb9d0a9811f04263b7261c6687a767cefa Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Sun, 3 Dec 2017 10:03:03 -0800 Subject: [PATCH] Fix connection leak. This was introduced when attempting to reuse ssh connection. --- zfs_replication_exporter.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zfs_replication_exporter.go b/zfs_replication_exporter.go index fcc3b1d..58b30aa 100644 --- a/zfs_replication_exporter.go +++ b/zfs_replication_exporter.go @@ -7,6 +7,7 @@ import ( "fmt" "io/ioutil" "net/http" + _ "net/http/pprof" "os" "path/filepath" "regexp" @@ -28,8 +29,8 @@ var ( const snapshotListCmd = "/sbin/zfs list -t snapshot -H -o name -s name" -// Example: @auto-20171001.1400-2w var ( + // Example: @auto-20171001.1400-2w snapshotPattern = regexp.MustCompile(`^[^@]+@auto-(\d{8}\.\d{4})-\d+[mwy]$`) snapshotFormat = "20060102.1504" @@ -186,8 +187,8 @@ func main() { HostKeyCallback: ssh.InsecureIgnoreHostKey(), Timeout: 5 * time.Second, } + var c *ssh.Client for { - var c *ssh.Client if c == nil { var err error c, err = ssh.Dial("tcp", host, config)