Fix race in ExecContext
When the context is cancelled, an interrupt should only be made if the operation is still ongoing.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user