From c281ee3b61e8ab53ff118866d72618ae8cce582b Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 13 Mar 2017 12:54:22 -0400 Subject: Updating server dependancies. Also adding github.com/jaytaylor/html2text and gopkg.in/gomail.v2 (#5748) --- vendor/github.com/lib/pq/conn_go18.go | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'vendor/github.com/lib/pq/conn_go18.go') diff --git a/vendor/github.com/lib/pq/conn_go18.go b/vendor/github.com/lib/pq/conn_go18.go index 0aca1d002..43cc35f7b 100644 --- a/vendor/github.com/lib/pq/conn_go18.go +++ b/vendor/github.com/lib/pq/conn_go18.go @@ -14,10 +14,7 @@ func (cn *conn) QueryContext(ctx context.Context, query string, args []driver.Na for i, nv := range args { list[i] = nv.Value } - var closed chan<- struct{} - if ctx.Done() != nil { - closed = watchCancel(ctx, cn.cancel) - } + closed := cn.watchCancel(ctx) r, err := cn.query(query, list) if err != nil { return nil, err @@ -33,8 +30,7 @@ func (cn *conn) ExecContext(ctx context.Context, query string, args []driver.Nam list[i] = nv.Value } - if ctx.Done() != nil { - closed := watchCancel(ctx, cn.cancel) + if closed := cn.watchCancel(ctx); closed != nil { defer close(closed) } @@ -53,22 +49,23 @@ func (cn *conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, if err != nil { return nil, err } - if ctx.Done() != nil { - cn.txnClosed = watchCancel(ctx, cn.cancel) - } + cn.txnClosed = cn.watchCancel(ctx) return tx, nil } -func watchCancel(ctx context.Context, cancel func()) chan<- struct{} { - closed := make(chan struct{}) - go func() { - select { - case <-ctx.Done(): - cancel() - case <-closed: - } - }() - return closed +func (cn *conn) watchCancel(ctx context.Context) chan<- struct{} { + if done := ctx.Done(); done != nil { + closed := make(chan struct{}) + go func() { + select { + case <-done: + cn.cancel() + case <-closed: + } + }() + return closed + } + return nil } func (cn *conn) cancel() { -- cgit v1.2.3-1-g7c22