diff options
author | Yasuhiro Matsumoto <mattn.jp@gmail.com> | 2017-08-02 01:43:14 +0900 |
---|---|---|
committer | Yasuhiro Matsumoto <mattn.jp@gmail.com> | 2017-08-02 01:43:14 +0900 |
commit | 1828334c4a7937cf4d957e36e995b9d6ba4fc535 (patch) | |
tree | 3f0b6391b44425ca586b1d3e93cc31a027f2e137 | |
parent | fix tests on tip (diff) | |
download | golite-1828334c4a7937cf4d957e36e995b9d6ba4fc535.tar.gz golite-1828334c4a7937cf4d957e36e995b9d6ba4fc535.tar.xz |
remove mutex
-rw-r--r-- | sqlite3.go | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -197,12 +197,12 @@ type SQLiteResult struct { // SQLiteRows implement sql.Rows. type SQLiteRows struct { - mu sync.Mutex s *SQLiteStmt nc int cols []string decltype []string cls bool + closed bool done chan struct{} } @@ -905,6 +905,7 @@ func (s *SQLiteStmt) query(ctx context.Context, args []namedValue) (driver.Rows, cols: nil, decltype: nil, cls: s.cls, + closed: false, done: make(chan struct{}), } @@ -977,14 +978,12 @@ func (s *SQLiteStmt) exec(ctx context.Context, args []namedValue) (driver.Result // Close the rows. func (rc *SQLiteRows) Close() error { - if rc.s.closed { + if rc.s.closed || rc.closed { return nil } + rc.closed = true if rc.done != nil { - rc.mu.Lock() close(rc.done) - rc.done = nil - rc.mu.Unlock() } if rc.cls { return rc.s.Close() |