aboutsummaryrefslogtreecommitdiff
path: root/sqlite3.go
diff options
context:
space:
mode:
authorNiklas Janlert <njanlert@planview.com>2017-11-21 13:40:00 +0100
committerNiklas Janlert <njanlert@planview.com>2017-11-21 13:40:00 +0100
commit58004848f1e59b2cef8add95bf5d13063ce4e003 (patch)
tree5bbecb2957b97369fa15b4be9b8f31f5847281a3 /sqlite3.go
parentMerge pull request #485 from mattn/sqlite3-3.21.0 (diff)
downloadgolite-58004848f1e59b2cef8add95bf5d13063ce4e003.tar.gz
golite-58004848f1e59b2cef8add95bf5d13063ce4e003.tar.xz
Fix race in ExecContext
When the context is cancelled, an interrupt should only be made if the operation is still ongoing.
Diffstat (limited to 'sqlite3.go')
-rw-r--r--sqlite3.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/sqlite3.go b/sqlite3.go
index a931735..c9edd40 100644
--- a/sqlite3.go
+++ b/sqlite3.go
@@ -1171,9 +1171,13 @@ func (s *SQLiteStmt) exec(ctx context.Context, args []namedValue) (driver.Result
defer close(done)
go func(db *C.sqlite3) {
select {
- case <-ctx.Done():
- C.sqlite3_interrupt(db)
case <-done:
+ case <-ctx.Done():
+ select {
+ case <-done:
+ default:
+ C.sqlite3_interrupt(db)
+ }
}
}(s.c.db)