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:
parent
45baf21111
commit
f8820f170c
@ -312,11 +312,10 @@ func (ks *KeyStore) Unlock(a accounts.Account, passphrase string) error {
|
|||||||
// Lock removes the private key with the given address from memory.
|
// Lock removes the private key with the given address from memory.
|
||||||
func (ks *KeyStore) Lock(addr common.Address) error {
|
func (ks *KeyStore) Lock(addr common.Address) error {
|
||||||
ks.mu.Lock()
|
ks.mu.Lock()
|
||||||
if unl, found := ks.unlocked[addr]; found {
|
unl, found := ks.unlocked[addr]
|
||||||
ks.mu.Unlock()
|
ks.mu.Unlock()
|
||||||
|
if found {
|
||||||
ks.expire(addr, unl, time.Duration(0)*time.Nanosecond)
|
ks.expire(addr, unl, time.Duration(0)*time.Nanosecond)
|
||||||
} else {
|
|
||||||
ks.mu.Unlock()
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,7 @@ func (hub *Hub) readPairings() error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer pairingFile.Close()
|
||||||
|
|
||||||
pairingData, err := io.ReadAll(pairingFile)
|
pairingData, err := io.ReadAll(pairingFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -73,6 +73,7 @@ func testConsoleLogging(t *testing.T, format string, tStart, tEnd int) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
defer readFile.Close()
|
||||||
wantLines := split(readFile)
|
wantLines := split(readFile)
|
||||||
haveLines := split(bytes.NewBuffer(haveB))
|
haveLines := split(bytes.NewBuffer(haveB))
|
||||||
for i, want := range wantLines {
|
for i, want := range wantLines {
|
||||||
@ -109,6 +110,7 @@ func TestJsonLogging(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
defer readFile.Close()
|
||||||
wantLines := split(readFile)
|
wantLines := split(readFile)
|
||||||
haveLines := split(bytes.NewBuffer(haveB))
|
haveLines := split(bytes.NewBuffer(haveB))
|
||||||
for i, wantLine := range wantLines {
|
for i, wantLine := range wantLines {
|
||||||
|
@ -101,6 +101,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
defer file.Close()
|
||||||
if err := json.NewDecoder(file).Decode(g); err != nil {
|
if err := json.NewDecoder(file).Decode(g); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user