mirror of https://github.com/jackc/pgx.git
Set socket to non-blocking mode before `doneChan` is allocated to avoid that channel leaked in case when `SetBlockingMode` will return error
parent
a83faa67f5
commit
3db7d1774e
|
@ -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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue