Skip to content

Commit 1828334

Browse files
committed
remove mutex
1 parent 42a4d14 commit 1828334

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

sqlite3.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,12 @@ type SQLiteResult struct {
197197

198198
// SQLiteRows implement sql.Rows.
199199
type SQLiteRows struct {
200-
mu sync.Mutex
201200
s *SQLiteStmt
202201
nc int
203202
cols []string
204203
decltype []string
205204
cls bool
205+
closed bool
206206
done chan struct{}
207207
}
208208

@@ -905,6 +905,7 @@ func (s *SQLiteStmt) query(ctx context.Context, args []namedValue) (driver.Rows,
905905
cols: nil,
906906
decltype: nil,
907907
cls: s.cls,
908+
closed: false,
908909
done: make(chan struct{}),
909910
}
910911

@@ -977,14 +978,12 @@ func (s *SQLiteStmt) exec(ctx context.Context, args []namedValue) (driver.Result
977978

978979
// Close the rows.
979980
func (rc *SQLiteRows) Close() error {
980-
if rc.s.closed {
981+
if rc.s.closed || rc.closed {
981982
return nil
982983
}
984+
rc.closed = true
983985
if rc.done != nil {
984-
rc.mu.Lock()
985986
close(rc.done)
986-
rc.done = nil
987-
rc.mu.Unlock()
988987
}
989988
if rc.cls {
990989
return rc.s.Close()

0 commit comments

Comments
 (0)