Fix connection leak.
This was introduced when attempting to reuse ssh connection.
This commit is contained in:
parent
77a8833d70
commit
4bd757cb9d
@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
_ "net/http/pprof"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
@ -28,8 +29,8 @@ var (
|
|||||||
|
|
||||||
const snapshotListCmd = "/sbin/zfs list -t snapshot -H -o name -s name"
|
const snapshotListCmd = "/sbin/zfs list -t snapshot -H -o name -s name"
|
||||||
|
|
||||||
// Example: @auto-20171001.1400-2w
|
|
||||||
var (
|
var (
|
||||||
|
// Example: @auto-20171001.1400-2w
|
||||||
snapshotPattern = regexp.MustCompile(`^[^@]+@auto-(\d{8}\.\d{4})-\d+[mwy]$`)
|
snapshotPattern = regexp.MustCompile(`^[^@]+@auto-(\d{8}\.\d{4})-\d+[mwy]$`)
|
||||||
snapshotFormat = "20060102.1504"
|
snapshotFormat = "20060102.1504"
|
||||||
|
|
||||||
@ -186,8 +187,8 @@ func main() {
|
|||||||
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||||
Timeout: 5 * time.Second,
|
Timeout: 5 * time.Second,
|
||||||
}
|
}
|
||||||
|
var c *ssh.Client
|
||||||
for {
|
for {
|
||||||
var c *ssh.Client
|
|
||||||
if c == nil {
|
if c == nil {
|
||||||
var err error
|
var err error
|
||||||
c, err = ssh.Dial("tcp", host, config)
|
c, err = ssh.Dial("tcp", host, config)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user