Always release ws context reader lock.
Previously, on a blockconnected notification, the websocket context reader lock was not always being given up properly. This change defers the unlock so it will always happen. This fixes an issue where wallet will stop responding (due to not being able to complete its handshake) on reconnect.
This commit is contained in:
parent
dcf2994905
commit
8b5413a4ac
1 changed files with 3 additions and 2 deletions
|
@ -1256,6 +1256,7 @@ func (s *rpcServer) websocketJSONHandler(walletNotification chan []byte,
|
||||||
// to each connected wallet.
|
// to each connected wallet.
|
||||||
func (s *rpcServer) NotifyBlockConnected(block *btcutil.Block) {
|
func (s *rpcServer) NotifyBlockConnected(block *btcutil.Block) {
|
||||||
s.ws.RLock()
|
s.ws.RLock()
|
||||||
|
defer s.ws.RUnlock()
|
||||||
hash, err := block.Sha()
|
hash, err := block.Sha()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Bad block; connected block notification dropped.")
|
log.Error("Bad block; connected block notification dropped.")
|
||||||
|
@ -1281,7 +1282,6 @@ func (s *rpcServer) NotifyBlockConnected(block *btcutil.Block) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.ws.RUnlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotifyBlockDisconnected creates and marshals a JSON message to notify
|
// NotifyBlockDisconnected creates and marshals a JSON message to notify
|
||||||
|
@ -1366,7 +1366,8 @@ func (s *rpcServer) newBlockNotifyCheckTxIn(tx *btcutil.Tx) {
|
||||||
// newBlockNotifyCheckTxOut is a helper function to iterate through
|
// newBlockNotifyCheckTxOut is a helper function to iterate through
|
||||||
// each transaction output of a new block and perform any checks and
|
// each transaction output of a new block and perform any checks and
|
||||||
// notify listening frontends when necessary.
|
// notify listening frontends when necessary.
|
||||||
func (s *rpcServer) newBlockNotifyCheckTxOut(block *btcutil.Block, tx *btcutil.Tx) {
|
func (s *rpcServer) newBlockNotifyCheckTxOut(block *btcutil.Block,
|
||||||
|
tx *btcutil.Tx) {
|
||||||
|
|
||||||
for i, txout := range tx.MsgTx().TxOut {
|
for i, txout := range tx.MsgTx().TxOut {
|
||||||
_, txaddrhash, err := btcscript.ScriptToAddrHash(txout.PkScript)
|
_, txaddrhash, err := btcscript.ScriptToAddrHash(txout.PkScript)
|
||||||
|
|
Loading…
Reference in a new issue