Fix unclosed database sessions and tunnels (#688)

This commit is contained in:
Dan Sosedoff 2023-09-10 11:46:31 -05:00 committed by GitHub
parent 14d8d80b86
commit 22daaad5a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -301,6 +301,7 @@ func Disconnect(c *gin.Context) {
return
}
DbClient = nil
successResponse(c, gin.H{"success": true})
}

View File

@ -69,7 +69,10 @@ func New() (*Client, error) {
}
func NewFromUrl(url string, sshInfo *shared.SSHInfo) (*Client, error) {
var tunnel *Tunnel
var (
tunnel *Tunnel
err error
)
if sshInfo != nil {
if command.Opts.DisableSSH {
@ -79,7 +82,7 @@ func NewFromUrl(url string, sshInfo *shared.SSHInfo) (*Client, error) {
fmt.Println("Opening SSH tunnel for:", sshInfo)
}
tunnel, err := NewTunnel(sshInfo, url)
tunnel, err = NewTunnel(sshInfo, url)
if err != nil {
tunnel.Close()
return nil, err
@ -524,6 +527,7 @@ func (client *Client) Close() error {
}
defer func() {
client.closed = true
client.tunnel = nil
}()
if client.tunnel != nil {