Skip to content

Commit 295211e

Browse files
committed
Merge #17445: zmq: Fix due to invalid argument and multiple notifiers
3e730bf zmq: Fix due to invalid argument and multiple notifiers (João Barbosa) Pull request description: ZMQ initialization is interrupted if any notifier fails, and in that case all notifiers are destroyed. The notifier shutdown assumes that the initialization had occurred. This is not valid when there are multiple notifiers and any except the last fails to initialize. Can be tested by running test/functional/interface_zmq.py from this branch with bitcoind from master. Closes #17185. ACKs for top commit: laanwj: Code review ACK 3e730bf, thanks for adding a test Tree-SHA512: 5da710e97dcbaa94896d019e75162d470f6d381ee07c60e5b3e9db93d11e8f7ca9bf2c509efa4486199e88c96c3e720cc96b4e35b62725d4c7db8e8e9bf6e09d
2 parents 7f3675b + 3e730bf commit 295211e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/zmq/zmqpublishnotifier.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ bool CZMQAbstractPublishNotifier::Initialize(void *pcontext)
112112

113113
void CZMQAbstractPublishNotifier::Shutdown()
114114
{
115-
assert(psocket);
115+
// Early return if Initialize was not called
116+
if (!psocket) return;
116117

117118
int count = mapPublishNotifiers.count(address);
118119

test/functional/interface_zmq.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ def test_basic(self):
5959
# Note that the publishing order is not defined in the documentation and
6060
# is subject to change.
6161
import zmq
62+
63+
# Invalid zmq arguments don't take down the node, see #17185.
64+
self.restart_node(0, ["-zmqpubrawtx=foo", "-zmqpubhashtx=bar"])
65+
6266
address = 'tcp://127.0.0.1:28332'
6367
socket = self.ctx.socket(zmq.SUB)
6468
socket.set(zmq.RCVTIMEO, 60000)

0 commit comments

Comments
 (0)