Browse Source
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.
v1.0.9-lin
João Barbosa
9 years ago
committed by
Jack Grigg
No known key found for this signature in database
GPG Key ID: 6A6914DAFBEA00DA
3 changed files with
10 additions and
6 deletions
src/init.cpp
src/zmq/zmqnotificationinterface.cpp
src/zmq/zmqnotificationinterface.h
@ -208,7 +208,6 @@ void Shutdown()
# if ENABLE_ZMQ
if ( pzmqNotificationInterface ) {
UnregisterValidationInterface ( pzmqNotificationInterface ) ;
pzmqNotificationInterface - > Shutdown ( ) ;
delete pzmqNotificationInterface ;
pzmqNotificationInterface = NULL ;
}
@ -1170,7 +1169,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
pzmqNotificationInterface = CZMQNotificationInterface : : CreateWithArguments ( mapArgs ) ;
if ( pzmqNotificationInterface ) {
pzmqNotificationInterface - > Initialize ( ) ;
RegisterValidationInterface ( pzmqNotificationInterface ) ;
}
# endif
@ -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 fals e;
return tru e;
}
// Called during shutdown sequence
@ -18,10 +18,11 @@ public:
static CZMQNotificationInterface * CreateWithArguments ( const std : : map < std : : string , std : : string > & args ) ;
protected :
bool Initialize ( ) ;
void Shutdown ( ) ;
protected : // CValidationInterface
// CValidationInterface
void SyncTransaction ( const CTransaction & tx , const CBlock * pblock ) ;
void UpdatedBlockTip ( const uint256 & newHashTip ) ;