Skip to content

Commit 18dd46a

Browse files
liuhaoXDlaiwei
authored andcommitted
fix bug of closing connection in the conn pool (open-falcon#837)
close open-falcon#832
1 parent 46ec795 commit 18dd46a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

common/backend_pool/tsdb_backends.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424

2525
// TSDB
2626
type TsdbClient struct {
27-
cli net.Conn
27+
cli *struct{ net.Conn }
2828
name string
2929
}
3030

@@ -33,13 +33,13 @@ func (t TsdbClient) Name() string {
3333
}
3434

3535
func (t TsdbClient) Closed() bool {
36-
return t.cli == nil
36+
return t.cli.Conn == nil
3737
}
3838

3939
func (t TsdbClient) Close() error {
4040
if t.cli != nil {
4141
err := t.cli.Close()
42-
t.cli = nil
42+
t.cli.Conn = nil
4343
return err
4444
}
4545
return nil
@@ -59,7 +59,10 @@ func newTsdbConnPool(address string, maxConns int, maxIdle int, connTimeout int)
5959
return nil, err
6060
}
6161

62-
return TsdbClient{conn, name}, nil
62+
return TsdbClient{
63+
cli: &struct{ net.Conn }{conn},
64+
name: name,
65+
}, nil
6366
}
6467

6568
return pool

0 commit comments

Comments
 (0)