mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-01-11 09:20:17 +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) {
|
||||
globalLock.Lock()
|
||||
defer globalLock.Unlock()
|
||||
globalLock.RLock()
|
||||
|
||||
countStmt := ss.txStmt(ss.backend.countStmt)
|
||||
if err = countStmt.QueryRow().Scan(&n); err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
err = nil
|
||||
}
|
||||
globalLock.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
keysStmt := ss.txStmt(ss.backend.keysStmt)
|
||||
var rows *sql.Rows
|
||||
if rows, err = keysStmt.Query(); err != nil {
|
||||
globalLock.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
keys = make(chan []byte)
|
||||
go func() {
|
||||
defer globalLock.RUnlock()
|
||||
defer rows.Close()
|
||||
defer close(keys)
|
||||
for rows.Next() {
|
||||
|
Loading…
Reference in New Issue
Block a user