Commit 6e59c73a authored by Daniel Theophanes's avatar Daniel Theophanes

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: 's avatarYasuhiro MATSUMOTO <mattn.jp@gmail.com>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 377a2cb2
......@@ -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)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment