accounts, cmd/geth, core: close opened files (#29598)

* fix: open file used up but not closed

* feat: more same case

* feat: accept conversation
This commit is contained in:
Daniel Liu 2025-01-14 10:56:17 +08:00
parent 02a3aa13c1
commit ef71887d7a
3 changed files with 5 additions and 4 deletions

View file

@ -323,11 +323,10 @@ func (ks *KeyStore) Unlock(a accounts.Account, passphrase string) error {
// Lock removes the private key with the given address from memory.
func (ks *KeyStore) Lock(addr common.Address) error {
ks.mu.Lock()
if unl, found := ks.unlocked[addr]; found {
ks.mu.Unlock()
unl, found := ks.unlocked[addr]
ks.mu.Unlock()
if found {
ks.expire(addr, unl, time.Duration(0)*time.Nanosecond)
} else {
ks.mu.Unlock()
}
return nil
}

View file

@ -95,6 +95,7 @@ func (hub *Hub) readPairings() error {
}
return err
}
defer pairingFile.Close()
pairingData, err := io.ReadAll(pairingFile)
if err != nil {

View file

@ -78,6 +78,7 @@ func main() {
if err != nil {
panic(err)
}
defer file.Close()
if err := json.NewDecoder(file).Decode(g); err != nil {
panic(err)
}