aboutsummaryrefslogtreecommitdiff
path: root/sqlite3.go
diff options
context:
space:
mode:
authorYasuhiro Matsumoto <mattn.jp@gmail.com>2017-02-11 21:47:11 +0900
committerYasuhiro Matsumoto <mattn.jp@gmail.com>2017-02-11 21:48:33 +0900
commit588cd3292ba03bb748befd607cc5c72e13204533 (patch)
tree2538719d7117bd0be01992797e1324ae4e0ba233 /sqlite3.go
parentMerge pull request #378 from AlekSi/patch-1 (diff)
downloadgolite-588cd3292ba03bb748befd607cc5c72e13204533.tar.gz
golite-588cd3292ba03bb748befd607cc5c72e13204533.tar.xz
fixes race
Diffstat (limited to 'sqlite3.go')
-rw-r--r--sqlite3.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/sqlite3.go b/sqlite3.go
index efb50b9..f5699e4 100644
--- a/sqlite3.go
+++ b/sqlite3.go
@@ -766,14 +766,18 @@ func (s *SQLiteStmt) query(ctx context.Context, args []namedValue) (driver.Rows,
done: make(chan struct{}),
}
- go func() {
+ go func(db *C.sqlite3) {
select {
case <-ctx.Done():
- C.sqlite3_interrupt(s.c.db)
- rows.Close()
+ select {
+ case <-rows.done:
+ default:
+ C.sqlite3_interrupt(s.c.db)
+ rows.Close()
+ }
case <-rows.done:
}
- }()
+ }(s.c.db)
return rows, nil
}