summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/Application.cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2017-04-22 18:02:53 -0400
committerBernard Normier <bernard@zeroc.com>2017-04-22 18:02:53 -0400
commitbd960c70612403251494030dffdaa86cf46a6384 (patch)
tree3618f57a3d89c3eab97b0d42f7730e62143408dd /cpp/src/Ice/Application.cpp
parentFix (ICE-7780) - Glacier2::Application cleanup (diff)
downloadice-bd960c70612403251494030dffdaa86cf46a6384.tar.bz2
ice-bd960c70612403251494030dffdaa86cf46a6384.tar.xz
ice-bd960c70612403251494030dffdaa86cf46a6384.zip
Improved C++11 version of CtrlCHandler
Diffstat (limited to 'cpp/src/Ice/Application.cpp')
-rw-r--r--cpp/src/Ice/Application.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/cpp/src/Ice/Application.cpp b/cpp/src/Ice/Application.cpp
index c689b453fbb..1fafb4370bb 100644
--- a/cpp/src/Ice/Application.cpp
+++ b/cpp/src/Ice/Application.cpp
@@ -10,7 +10,6 @@
#include <Ice/Application.h>
#include <Ice/LoggerI.h>
#include <Ice/LoggerUtil.h>
-#include <IceUtil/CtrlCHandler.h>
#include <Ice/ArgVector.h>
#ifdef _WIN32
@@ -46,8 +45,8 @@ namespace
//
// Variables than can change while run() and communicator->destroy() are running!
//
-bool _released = false;
-CtrlCHandlerCallback _previousCallback = 0;
+bool _released = true;
+CtrlCHandlerCallback _previousCallback = ICE_NULLPTR;
//
// Variables that are immutable during run() and until communicator->destroy() has returned;
@@ -248,7 +247,7 @@ Ice::Application::destroyOnInterrupt()
if(_ctrlCHandler != 0)
{
Mutex::Lock lock(_mutex); // we serialize all the interrupt-setting
- if(_ctrlCHandler->getCallback() == holdInterruptCallback)
+ if(!_released)
{
_released = true;
_condVar.signal();
@@ -271,7 +270,7 @@ Ice::Application::shutdownOnInterrupt()
if(_ctrlCHandler != 0)
{
Mutex::Lock lock(_mutex); // we serialize all the interrupt-setting
- if(_ctrlCHandler->getCallback() == holdInterruptCallback)
+ if(!_released)
{
_released = true;
_condVar.signal();
@@ -294,7 +293,7 @@ Ice::Application::ignoreInterrupt()
if(_ctrlCHandler != 0)
{
Mutex::Lock lock(_mutex); // we serialize all the interrupt-setting
- if(_ctrlCHandler->getCallback() == holdInterruptCallback)
+ if(!_released)
{
_released = true;
_condVar.signal();
@@ -317,7 +316,7 @@ Ice::Application::callbackOnInterrupt()
if(_ctrlCHandler != 0)
{
Mutex::Lock lock(_mutex); // we serialize all the interrupt-setting
- if(_ctrlCHandler->getCallback() == holdInterruptCallback)
+ if(!_released)
{
_released = true;
_condVar.signal();
@@ -340,7 +339,7 @@ Ice::Application::holdInterrupt()
if(_ctrlCHandler != 0)
{
Mutex::Lock lock(_mutex); // we serialize all the interrupt-setting
- if(_ctrlCHandler->getCallback() != holdInterruptCallback)
+ if(_released)
{
_previousCallback = _ctrlCHandler->getCallback();
_released = false;
@@ -364,7 +363,7 @@ Ice::Application::releaseInterrupt()
if(_ctrlCHandler != 0)
{
Mutex::Lock lock(_mutex); // we serialize all the interrupt-setting
- if(_ctrlCHandler->getCallback() == holdInterruptCallback)
+ if(!_released)
{
//
// Note that it's very possible no signal is held;
@@ -502,7 +501,7 @@ Ice::Application::doMain(int argc, char* argv[], const InitializationData& initD
void
Ice::Application::holdInterruptCallback(int signal)
{
- CtrlCHandlerCallback callback = 0;
+ CtrlCHandlerCallback callback = ICE_NULLPTR;
{
Mutex::Lock lock(_mutex);
while(!_released)
@@ -521,7 +520,7 @@ Ice::Application::holdInterruptCallback(int signal)
callback = _ctrlCHandler->getCallback();
}
- if(callback != 0)
+ if(callback)
{
callback(signal);
}