summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/Application.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2008-01-29 14:57:43 -0800
committerMark Spruiell <mes@zeroc.com>2008-01-29 14:57:43 -0800
commitfdb1fba472f6f2f41667f76a543044df14beea61 (patch)
tree4f0ba613f197f9de74b2ee10dc3ca26a7baf49b6 /cpp/src/Ice/Application.cpp
parentFixed merge conflict (diff)
downloadice-fdb1fba472f6f2f41667f76a543044df14beea61.tar.bz2
ice-fdb1fba472f6f2f41667f76a543044df14beea61.tar.xz
ice-fdb1fba472f6f2f41667f76a543044df14beea61.zip
C# changes:
- Adding UNSAFE make macro. - Adding signal support to Ice.Application on Mono. - General cleanup in Application (C# & C++).
Diffstat (limited to 'cpp/src/Ice/Application.cpp')
-rw-r--r--cpp/src/Ice/Application.cpp70
1 files changed, 32 insertions, 38 deletions
diff --git a/cpp/src/Ice/Application.cpp b/cpp/src/Ice/Application.cpp
index 85d89d4a33a..48811380ee8 100644
--- a/cpp/src/Ice/Application.cpp
+++ b/cpp/src/Ice/Application.cpp
@@ -42,7 +42,7 @@ static CtrlCHandlerCallback _previousCallback = 0;
// before and after run(), and once communicator->destroy() has returned, we assume that
// only the main thread and CtrlCHandler threads are running.
//
-static const char* _appName = 0;
+static string _appName;
static Application* _application;
static CommunicatorPtr _communicator;
static CtrlCHandler* _ctrlCHandler = 0;
@@ -118,31 +118,26 @@ destroyOnInterruptCallback(int signal)
_destroyed = true;
}
- assert(_communicator != 0);
-
try
{
+ assert(_communicator != 0);
_communicator->destroy();
}
catch(const std::exception& ex)
{
- cerr << _appName << " (while destroying in response to signal " << signal
- << "): " << ex.what() << endl;
+ cerr << _appName << " (while destroying in response to signal " << signal << "): " << ex.what() << endl;
}
catch(const std::string& msg)
{
- cerr << _appName << " (while destroying in response to signal " << signal
- << "): " << msg << endl;
+ cerr << _appName << " (while destroying in response to signal " << signal << "): " << msg << endl;
}
- catch(const char * msg)
+ catch(const char* msg)
{
- cerr << _appName << " (while destroying in response to signal " << signal
- << "): " << msg << endl;
+ cerr << _appName << " (while destroying in response to signal " << signal << "): " << msg << endl;
}
catch(...)
{
- cerr << _appName << " (while destroying in response to signal " << signal
- << "): unknown exception" << endl;
+ cerr << _appName << " (while destroying in response to signal " << signal << "): unknown exception" << endl;
}
{
@@ -152,7 +147,6 @@ destroyOnInterruptCallback(int signal)
_condVar->signal();
}
-
static void
shutdownOnInterruptCallback(int signal)
{
@@ -169,35 +163,33 @@ shutdownOnInterruptCallback(int signal)
{
return;
}
+
assert(!_callbackInProgress);
_callbackInProgress = true;
_interrupted = true;
}
- assert(_communicator != 0);
try
{
+ assert(_communicator != 0);
_communicator->shutdown();
}
catch(const std::exception& ex)
{
- cerr << _appName << " (while shutting down in response to signal " << signal
- << "): std::exception: " << ex.what() << endl;
+ cerr << _appName << " (while shutting down in response to signal " << signal << "): std::exception: "
+ << ex.what() << endl;
}
catch(const std::string& msg)
{
- cerr << _appName << " (while shutting down in response to signal " << signal
- << "): " << msg << endl;
+ cerr << _appName << " (while shutting down in response to signal " << signal << "): " << msg << endl;
}
- catch(const char * msg)
+ catch(const char* msg)
{
- cerr << _appName << " (while shutting down in response to signal " << signal
- << "): " << msg << endl;
+ cerr << _appName << " (while shutting down in response to signal " << signal << "): " << msg << endl;
}
catch(...)
{
- cerr << _appName << " (while shutting down in response to signal " << signal
- << "): unknown exception" << endl;
+ cerr << _appName << " (while shutting down in response to signal " << signal << "): unknown exception" << endl;
}
{
@@ -226,30 +218,27 @@ callbackOnInterruptCallback(int signal)
_interrupted = true;
}
- assert(_application != 0);
try
{
+ assert(_application != 0);
_application->interruptCallback(signal);
}
catch(const std::exception& ex)
{
- cerr << _appName << " (while interrupting in response to signal " << signal
- << "): std::exception: " << ex.what() << endl;
+ cerr << _appName << " (while interrupting in response to signal " << signal << "): std::exception: "
+ << ex.what() << endl;
}
catch(const std::string& msg)
{
- cerr << _appName << " (while interrupting in response to signal " << signal
- << "): " << msg << endl;
+ cerr << _appName << " (while interrupting in response to signal " << signal << "): " << msg << endl;
}
- catch(const char * msg)
+ catch(const char* msg)
{
- cerr << _appName << " (while interrupting in response to signal " << signal
- << "): " << msg << endl;
+ cerr << _appName << " (while interrupting in response to signal " << signal << "): " << msg << endl;
}
catch(...)
{
- cerr << _appName << " (while interrupting in response to signal " << signal
- << "): unknown exception" << endl;
+ cerr << _appName << " (while interrupting in response to signal " << signal << "): unknown exception" << endl;
}
{
@@ -259,7 +248,6 @@ callbackOnInterruptCallback(int signal)
_condVar->signal();
}
-
Ice::Application::Application(SignalPolicy signalPolicy)
{
_signalPolicy = signalPolicy;
@@ -304,7 +292,6 @@ Ice::Application::main(int argc, char* argv[], const char* configFile)
return main(argc, argv, initData);
}
-
int
Ice::Application::main(int argc, char* argv[], const InitializationData& initData)
{
@@ -402,7 +389,7 @@ Ice::Application::interruptCallback(int)
const char*
Ice::Application::appName()
{
- return _appName;
+ return _appName.c_str();
}
CommunicatorPtr
@@ -607,7 +594,11 @@ Ice::Application::mainInternal(int argc, char* argv[], const InitializationData&
//
// The default is to destroy when a signal is received.
//
- destroyOnInterrupt();
+ if(_signalPolicy == HandleSignals)
+ {
+ destroyOnInterrupt();
+ }
+
status = run(argc, argv);
}
catch(const std::exception& ex)
@@ -636,7 +627,10 @@ Ice::Application::mainInternal(int argc, char* argv[], const InitializationData&
// it would not make sense to release a held signal to run
// shutdown or destroy.
//
- ignoreInterrupt();
+ if(_signalPolicy == HandleSignals)
+ {
+ ignoreInterrupt();
+ }
{
StaticMutex::Lock lock(_mutex);