Set socket to non-blocking mode before doneChan is allocated to avoid that channel leaked in case when SetBlockingMode will return error
This commit is contained in:
committed by
Jack Christensen
parent
a83faa67f5
commit
3db7d1774e
+3
-3
@@ -132,9 +132,6 @@ func (ct *copyFrom) run(ctx context.Context) (int64, error) {
|
|||||||
return 0, fmt.Errorf("unknown QueryExecMode: %v", ct.mode)
|
return 0, fmt.Errorf("unknown QueryExecMode: %v", ct.mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
r, w := io.Pipe()
|
|
||||||
doneChan := make(chan struct{})
|
|
||||||
|
|
||||||
if realNbConn, ok := ct.conn.pgConn.Conn().(*nbconn.NetConn); ok {
|
if realNbConn, ok := ct.conn.pgConn.Conn().(*nbconn.NetConn); ok {
|
||||||
if err := realNbConn.SetBlockingMode(false); err != nil {
|
if err := realNbConn.SetBlockingMode(false); err != nil {
|
||||||
return 0, fmt.Errorf("cannot set socket non-blocking mode: %w", err)
|
return 0, fmt.Errorf("cannot set socket non-blocking mode: %w", err)
|
||||||
@@ -146,6 +143,9 @@ func (ct *copyFrom) run(ctx context.Context) (int64, error) {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r, w := io.Pipe()
|
||||||
|
doneChan := make(chan struct{})
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer close(doneChan)
|
defer close(doneChan)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user