mirror of https://github.com/jackc/pgx.git
wip
parent
50b0bea9e5
commit
09d37880ba
|
@ -0,0 +1,11 @@
|
||||||
|
Extract all locking state into a separate struct that will encapsulate locking and state change behavior.
|
||||||
|
|
||||||
|
This struct should add or subsume at least the following:
|
||||||
|
* alive
|
||||||
|
* closingLock
|
||||||
|
* ctxInProgress (though this may be restructured because it's possible a Tx may have a ctx and a query run in that Tx could have one)
|
||||||
|
* busy
|
||||||
|
* lock/unlock
|
||||||
|
* Tx in-progress
|
||||||
|
* Rows in-progress
|
||||||
|
* ConnPool checked-out or checked-in - maybe include reference to conn pool
|
7
conn.go
7
conn.go
|
@ -1403,6 +1403,9 @@ func (c *Conn) termContext(opErr error) error {
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case err = <-c.closedChan:
|
case err = <-c.closedChan:
|
||||||
|
if dlErr := c.conn.SetDeadline(time.Time{}); dlErr != nil {
|
||||||
|
c.Close() // Close connection if unable to disable deadline
|
||||||
|
}
|
||||||
if opErr == nil {
|
if opErr == nil {
|
||||||
err = nil
|
err = nil
|
||||||
}
|
}
|
||||||
|
@ -1418,7 +1421,9 @@ func (c *Conn) contextHandler(ctx context.Context) {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
c.cancelQuery()
|
c.cancelQuery()
|
||||||
c.Close()
|
if err := c.conn.SetDeadline(time.Now()); err != nil {
|
||||||
|
c.Close() // Close connection if unable to set deadline
|
||||||
|
}
|
||||||
c.closedChan <- ctx.Err()
|
c.closedChan <- ctx.Err()
|
||||||
case <-c.doneChan:
|
case <-c.doneChan:
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue