aboutsummaryrefslogtreecommitdiff
path: root/src/zmq/zmqnotificationinterface.cpp
diff options
context:
space:
mode:
authorJoão Barbosa <joao@bitreserve.org>2015-11-01 18:09:17 +0000
committerJoão Barbosa <joao@bitreserve.org>2015-11-04 10:36:00 +0000
commitde0499d3b8352334357c8d60931cd5d2be5ab61d (patch)
treedebaa2e8f9671650860d827cedbdac27ca79b243 /src/zmq/zmqnotificationinterface.cpp
parent02a95be97759e70d9e7537775c95eec219c8333e (diff)
Fix ZMQ Notification initialization and shutdown
Moves the call Initialize() from init.cpp to CreateWithArguments() and handles the return value. Moves the call Shutdown() from init.cpp to destructor. Changes Initialize() and Shutdown() to protected members.
Diffstat (limited to 'src/zmq/zmqnotificationinterface.cpp')
-rw-r--r--src/zmq/zmqnotificationinterface.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/zmq/zmqnotificationinterface.cpp b/src/zmq/zmqnotificationinterface.cpp
index 388b86707b..09fe3aeb4c 100644
--- a/src/zmq/zmqnotificationinterface.cpp
+++ b/src/zmq/zmqnotificationinterface.cpp
@@ -21,8 +21,7 @@ CZMQNotificationInterface::CZMQNotificationInterface() : pcontext(NULL)
CZMQNotificationInterface::~CZMQNotificationInterface()
{
- // ensure Shutdown if Initialize is called
- assert(!pcontext);
+ Shutdown();
for (std::list<CZMQAbstractNotifier*>::iterator i=notifiers.begin(); i!=notifiers.end(); ++i)
{
@@ -59,6 +58,12 @@ CZMQNotificationInterface* CZMQNotificationInterface::CreateWithArguments(const
{
notificationInterface = new CZMQNotificationInterface();
notificationInterface->notifiers = notifiers;
+
+ if (!notificationInterface->Initialize())
+ {
+ delete notificationInterface;
+ notificationInterface = NULL;
+ }
}
return notificationInterface;
@@ -99,7 +104,7 @@ bool CZMQNotificationInterface::Initialize()
return false;
}
- return false;
+ return true;
}
// Called during shutdown sequence