Skip to content

Commit aa03fb3

Browse files
committed
Merge pull request #6927
de0499d Fix ZMQ Notification initialization and shutdown (João Barbosa)
2 parents 29c3c43 + de0499d commit aa03fb3

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/init.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ void Shutdown()
222222
#if ENABLE_ZMQ
223223
if (pzmqNotificationInterface) {
224224
UnregisterValidationInterface(pzmqNotificationInterface);
225-
pzmqNotificationInterface->Shutdown();
226225
delete pzmqNotificationInterface;
227226
pzmqNotificationInterface = NULL;
228227
}
@@ -1180,7 +1179,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
11801179
pzmqNotificationInterface = CZMQNotificationInterface::CreateWithArguments(mapArgs);
11811180

11821181
if (pzmqNotificationInterface) {
1183-
pzmqNotificationInterface->Initialize();
11841182
RegisterValidationInterface(pzmqNotificationInterface);
11851183
}
11861184
#endif

src/zmq/zmqnotificationinterface.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ CZMQNotificationInterface::CZMQNotificationInterface() : pcontext(NULL)
2121

2222
CZMQNotificationInterface::~CZMQNotificationInterface()
2323
{
24-
// ensure Shutdown if Initialize is called
25-
assert(!pcontext);
24+
Shutdown();
2625

2726
for (std::list<CZMQAbstractNotifier*>::iterator i=notifiers.begin(); i!=notifiers.end(); ++i)
2827
{
@@ -59,6 +58,12 @@ CZMQNotificationInterface* CZMQNotificationInterface::CreateWithArguments(const
5958
{
6059
notificationInterface = new CZMQNotificationInterface();
6160
notificationInterface->notifiers = notifiers;
61+
62+
if (!notificationInterface->Initialize())
63+
{
64+
delete notificationInterface;
65+
notificationInterface = NULL;
66+
}
6267
}
6368

6469
return notificationInterface;
@@ -99,7 +104,7 @@ bool CZMQNotificationInterface::Initialize()
99104
return false;
100105
}
101106

102-
return false;
107+
return true;
103108
}
104109

105110
// Called during shutdown sequence

src/zmq/zmqnotificationinterface.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ class CZMQNotificationInterface : public CValidationInterface
1919

2020
static CZMQNotificationInterface* CreateWithArguments(const std::map<std::string, std::string> &args);
2121

22+
protected:
2223
bool Initialize();
2324
void Shutdown();
2425

25-
protected: // CValidationInterface
26+
// CValidationInterface
2627
void SyncTransaction(const CTransaction &tx, const CBlock *pblock);
2728
void UpdatedBlockTip(const CBlockIndex *pindex);
2829

0 commit comments

Comments
 (0)