aboutsummaryrefslogtreecommitdiff
path: root/sqlite3.go
diff options
context:
space:
mode:
authorYasuhiro Matsumoto <mattn.jp@gmail.com>2017-08-02 00:06:18 +0900
committerYasuhiro Matsumoto <mattn.jp@gmail.com>2017-08-02 00:06:18 +0900
commit569232dc083e6dbcaab291f39bd5f78af2aedf08 (patch)
tree0af6bf0ce4a5b327bf91813389fc7ea68e5aee8d /sqlite3.go
parentMerge pull request #436 from zombiezen/recursivetriggers (diff)
downloadgolite-569232dc083e6dbcaab291f39bd5f78af2aedf08.tar.gz
golite-569232dc083e6dbcaab291f39bd5f78af2aedf08.tar.xz
fix possibly double Close.
fixes #448
Diffstat (limited to 'sqlite3.go')
-rw-r--r--sqlite3.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/sqlite3.go b/sqlite3.go
index 2ebf7e7..3fc7354 100644
--- a/sqlite3.go
+++ b/sqlite3.go
@@ -167,7 +167,7 @@ type SQLiteDriver struct {
// SQLiteConn implement sql.Conn.
type SQLiteConn struct {
- dbMu sync.Mutex
+ mu sync.Mutex
db *C.sqlite3
loc *time.Location
txlock string
@@ -197,6 +197,7 @@ type SQLiteResult struct {
// SQLiteRows implement sql.Rows.
type SQLiteRows struct {
+ mu sync.Mutex
s *SQLiteStmt
nc int
cols []string
@@ -761,9 +762,9 @@ func (c *SQLiteConn) Close() error {
return c.lastError()
}
deleteHandles(c)
- c.dbMu.Lock()
+ c.mu.Lock()
c.db = nil
- c.dbMu.Unlock()
+ c.mu.Unlock()
runtime.SetFinalizer(c, nil)
return nil
}
@@ -772,8 +773,8 @@ func (c *SQLiteConn) dbConnOpen() bool {
if c == nil {
return false
}
- c.dbMu.Lock()
- defer c.dbMu.Unlock()
+ c.mu.Lock()
+ defer c.mu.Unlock()
return c.db != nil
}
@@ -980,7 +981,10 @@ func (rc *SQLiteRows) Close() error {
return nil
}
if rc.done != nil {
+ rc.mu.Lock()
close(rc.done)
+ rc.done = nil
+ rc.mu.Unlock()
}
if rc.cls {
return rc.s.Close()