diff options
| author | Daniel Theophanes <kardianos@gmail.com> | 2018-03-25 17:19:47 -0700 |
|---|---|---|
| committer | Daniel Theophanes <kardianos@gmail.com> | 2018-03-27 18:40:46 +0000 |
| commit | 6e59c73a9fe4eab3e09c6287f69c48837580dbb4 (patch) | |
| tree | 15df07f569c86caedecf0d7b4801853fba6501b7 /src/database/sql | |
| parent | 377a2cb2d20f37f259ca533c7a4b026dbbf8e585 (diff) | |
| download | go-6e59c73a9fe4eab3e09c6287f69c48837580dbb4.tar.xz | |
database/sql: check to see if ctx is cancelable before await
Prevent queries from starting a goroutine if the context is
not able to be canceled.
Fixes #23879
Change-Id: I392047bd53d7f796219dd12ee11b07303658fdaf
Reviewed-on: https://go-review.googlesource.com/102478
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/database/sql')
| -rw-r--r-- | src/database/sql/sql.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/database/sql/sql.go b/src/database/sql/sql.go index 088e118df7..c8666653ba 100644 --- a/src/database/sql/sql.go +++ b/src/database/sql/sql.go @@ -2563,6 +2563,9 @@ type Rows struct { } func (rs *Rows) initContextClose(ctx, txctx context.Context) { + if ctx.Done() == nil && (txctx == nil || txctx.Done() == nil) { + return + } ctx, rs.cancel = context.WithCancel(ctx) go rs.awaitDone(ctx, txctx) } |
