mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-11-16 15:20:20 +01:00
Sqlite backend: Unlock the mutex in Allkeys correctly.
This commit is contained in:
parent
d54af34288
commit
d96d352db8
|
@ -216,24 +216,27 @@ func (ss *SqliteSession) CommitTransaction() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ss *SqliteSession) AllKeys(hash []byte) (keys chan []byte, n int, err error) {
|
func (ss *SqliteSession) AllKeys(hash []byte) (keys chan []byte, n int, err error) {
|
||||||
globalLock.Lock()
|
globalLock.RLock()
|
||||||
defer globalLock.Unlock()
|
|
||||||
|
|
||||||
countStmt := ss.txStmt(ss.backend.countStmt)
|
countStmt := ss.txStmt(ss.backend.countStmt)
|
||||||
if err = countStmt.QueryRow().Scan(&n); err != nil {
|
if err = countStmt.QueryRow().Scan(&n); err != nil {
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
err = nil
|
err = nil
|
||||||
}
|
}
|
||||||
|
globalLock.RUnlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
keysStmt := ss.txStmt(ss.backend.keysStmt)
|
keysStmt := ss.txStmt(ss.backend.keysStmt)
|
||||||
var rows *sql.Rows
|
var rows *sql.Rows
|
||||||
if rows, err = keysStmt.Query(); err != nil {
|
if rows, err = keysStmt.Query(); err != nil {
|
||||||
|
globalLock.RUnlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
keys = make(chan []byte)
|
keys = make(chan []byte)
|
||||||
go func() {
|
go func() {
|
||||||
|
defer globalLock.RUnlock()
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
defer close(keys)
|
defer close(keys)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user