2
0

Set socket to non-blocking mode in Read, Flush and BufferReadUntilBlock operations

This commit is contained in:
Dmitry K
2023-03-19 03:18:56 +03:00
committed by Jack Christensen
parent 3db7d1774e
commit b2b4fbcf57
3 changed files with 71 additions and 55 deletions
-12
View File
@@ -4,7 +4,6 @@ import (
"bytes"
"context"
"fmt"
"github.com/jackc/pgx/v5/internal/nbconn"
"io"
"github.com/jackc/pgx/v5/internal/pgio"
@@ -132,17 +131,6 @@ func (ct *copyFrom) run(ctx context.Context) (int64, error) {
return 0, fmt.Errorf("unknown QueryExecMode: %v", ct.mode)
}
if realNbConn, ok := ct.conn.pgConn.Conn().(*nbconn.NetConn); ok {
if err := realNbConn.SetBlockingMode(false); err != nil {
return 0, fmt.Errorf("cannot set socket non-blocking mode: %w", err)
}
defer func() {
// TODO: Deal with it
_ = realNbConn.SetBlockingMode(true)
}()
}
r, w := io.Pipe()
doneChan := make(chan struct{})