mirror of https://github.com/mattn/go-sqlite3.git
remove mutex
This commit is contained in:
parent
42a4d148c2
commit
1828334c4a
|
@ -197,12 +197,12 @@ type SQLiteResult struct {
|
||||||
|
|
||||||
// SQLiteRows implement sql.Rows.
|
// SQLiteRows implement sql.Rows.
|
||||||
type SQLiteRows struct {
|
type SQLiteRows struct {
|
||||||
mu sync.Mutex
|
|
||||||
s *SQLiteStmt
|
s *SQLiteStmt
|
||||||
nc int
|
nc int
|
||||||
cols []string
|
cols []string
|
||||||
decltype []string
|
decltype []string
|
||||||
cls bool
|
cls bool
|
||||||
|
closed bool
|
||||||
done chan struct{}
|
done chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -905,6 +905,7 @@ func (s *SQLiteStmt) query(ctx context.Context, args []namedValue) (driver.Rows,
|
||||||
cols: nil,
|
cols: nil,
|
||||||
decltype: nil,
|
decltype: nil,
|
||||||
cls: s.cls,
|
cls: s.cls,
|
||||||
|
closed: false,
|
||||||
done: make(chan struct{}),
|
done: make(chan struct{}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -977,14 +978,12 @@ func (s *SQLiteStmt) exec(ctx context.Context, args []namedValue) (driver.Result
|
||||||
|
|
||||||
// Close the rows.
|
// Close the rows.
|
||||||
func (rc *SQLiteRows) Close() error {
|
func (rc *SQLiteRows) Close() error {
|
||||||
if rc.s.closed {
|
if rc.s.closed || rc.closed {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
rc.closed = true
|
||||||
if rc.done != nil {
|
if rc.done != nil {
|
||||||
rc.mu.Lock()
|
|
||||||
close(rc.done)
|
close(rc.done)
|
||||||
rc.done = nil
|
|
||||||
rc.mu.Unlock()
|
|
||||||
}
|
}
|
||||||
if rc.cls {
|
if rc.cls {
|
||||||
return rc.s.Close()
|
return rc.s.Close()
|
||||||
|
|
Loading…
Reference in New Issue