diff options
author | Benoit Foucher <benoit@zeroc.com> | 2005-05-11 15:33:51 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2005-05-11 15:33:51 +0000 |
commit | 6cfcf924e6252e6fe129b4f6bbcbd47d7727378c (patch) | |
tree | 8c8c7ffa31cf96550b1dc2c49c925fc4a037c88a /cpp/src | |
parent | Fix (diff) | |
download | ice-6cfcf924e6252e6fe129b4f6bbcbd47d7727378c.tar.bz2 ice-6cfcf924e6252e6fe129b4f6bbcbd47d7727378c.tar.xz ice-6cfcf924e6252e6fe129b4f6bbcbd47d7727378c.zip |
Fixed Ice::Service::shutdown() to catch exceptions.
Diffstat (limited to 'cpp/src')
-rwxr-xr-x | cpp/src/Ice/Service.cpp | 38 | ||||
-rw-r--r-- | cpp/src/IceGrid/Activator.cpp | 40 | ||||
-rw-r--r-- | cpp/src/IceGrid/Parser.cpp | 28 |
3 files changed, 73 insertions, 33 deletions
diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp index d02f7050c86..fc4d4647e92 100755 --- a/cpp/src/Ice/Service.cpp +++ b/cpp/src/Ice/Service.cpp @@ -119,7 +119,23 @@ Ice::Service::shutdown() { if(_communicator) { - _communicator->shutdown(); + try + { + _communicator->shutdown(); + } + catch(const CommunicatorDestroyedException&) + { + // + // Expected if the service communicator is being + // destroyed. + // + } + catch(const Ice::Exception& ex) + { + ostringstream ostr; + ostr << "exception during shutdown:\n" << ex; + warning(ostr.str()); + } } return true; } @@ -460,25 +476,25 @@ Ice::Service::run(int& argc, char* argv[]) catch(const IceUtil::Exception& ex) { ostringstream ostr; - ostr << "service caught unhandled Ice exception:" << endl << ex; + ostr << "service caught unhandled Ice exception:\n" << ex; error(ostr.str()); } catch(const std::exception& ex) { ostringstream ostr; - ostr << "service caught unhandled std::exception:" << endl << ex.what(); + ostr << "service caught unhandled std::exception:\n" << ex.what(); error(ostr.str()); } catch(const std::string& msg) { ostringstream ostr; - ostr << "service caught unhandled exception:" << endl << msg; + ostr << "service caught unhandled exception:\n" << msg; error(ostr.str()); } catch(const char* msg) { ostringstream ostr; - ostr << "service caught unhandled exception:" << endl << msg; + ostr << "service caught unhandled exception:\n" << msg; error(ostr.str()); } catch(...) @@ -1186,7 +1202,7 @@ Ice::Service::serviceMain(int argc, char* argv[]) catch(const IceUtil::Exception& ex) { ostringstream ostr; - ostr << "service caught unhandled Ice exception:" << endl << ex; + ostr << "service caught unhandled Ice exception:\n" << ex; error(ostr.str()); } catch(...) @@ -1331,7 +1347,7 @@ Ice::Service::runDaemon(int argc, char* argv[]) continue; } - cerr << argv[0] << ": " << strerror(errno) << endl << flush; + cerr << argv[0] << ": " << strerror(errno) << endl; _exit(EXIT_FAILURE); } break; @@ -1354,8 +1370,8 @@ Ice::Service::runDaemon(int argc, char* argv[]) continue; } - cerr << argv[0] << ": I/O error while reading error message from child:" << endl - << strerror(errno) << endl << flush; + cerr << argv[0] << ": I/O error while reading error message from child:\n" + << strerror(errno) << endl; _exit(EXIT_FAILURE); } pos += n; @@ -1366,7 +1382,7 @@ Ice::Service::runDaemon(int argc, char* argv[]) { cerr << ':' << endl << msg; } - cerr << endl << flush; + cerr << endl; _exit(EXIT_FAILURE); } @@ -1563,7 +1579,7 @@ Ice::Service::runDaemon(int argc, char* argv[]) catch(const IceUtil::Exception& ex) { ostringstream ostr; - ostr << "service caught unhandled Ice exception:" << endl << ex; + ostr << "service caught unhandled Ice exception:\n" << ex; errMsg = ostr.str(); error(errMsg); } diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp index b01cbe326b1..30b727a1837 100644 --- a/cpp/src/IceGrid/Activator.cpp +++ b/cpp/src/IceGrid/Activator.cpp @@ -349,33 +349,37 @@ Activator::activate(const string& name, } string pwd = pwdPath; - #ifdef _WIN32 - // - // Get the absolute pathname of the executable. - // - char absbuf[_MAX_PATH]; - char* filePart; - if(SearchPath(NULL, path.c_str(), ".exe", _MAX_PATH, absbuf, &filePart) == 0) + if(path[0] != '.' && path[0] != '\\' && path[0] != '/' && !(path.size() > 1 && isalpha(path[0]) && path[1] == ':')) { - Error out(_traceLevels->logger); - out << "cannot convert `" << path << "' into an absolute path"; - return false; + // + // Get the absolute pathname of the executable. + // + char absbuf[_MAX_PATH]; + char* filePart; + string ext = path.size() <= 4 || path[path.size() - 4] != '.' ? ".exe" : ""; + if(SearchPath(NULL, path.c_str(), ext.c_str(), _MAX_PATH, absbuf, &filePart) == 0) + { + Error out(_traceLevels->logger); + out << "cannot convert `" << path << "' into an absolute path"; + return false; + } + path = absbuf; } - path = absbuf; // // Get the absolute pathname of the working directory. // if(!pwd.empty()) { - if(_fullpath(absbuf, pwd.c_str(), _MAX_PATH) == NULL) - { - Error out(_traceLevels->logger); - out << "cannot convert `" << pwd << "' into an absolute path"; - return false; - } - pwd = absbuf; + char absbuf[_MAX_PATH]; + if(_fullpath(absbuf, pwd.c_str(), _MAX_PATH) == NULL) + { + Error out(_traceLevels->logger); + out << "cannot convert `" << pwd << "' into an absolute path"; + return false; + } + pwd = absbuf; } #else // diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp index a8df0298e71..c9b31f21949 100644 --- a/cpp/src/IceGrid/Parser.cpp +++ b/cpp/src/IceGrid/Parser.cpp @@ -167,9 +167,19 @@ describe(IceUtil::Output& out, const Ice::CommunicatorPtr& communicator, const S if(!s->jvmOptions.empty()) { out << nl << "jvmOptions = '"; - for(Ice::StringSeq::const_iterator p = s->jvmOptions.begin(); p != s->jvmOptions.end();) + Ice::StringSeq::const_iterator p = s->jvmOptions.begin(); + while(p != s->jvmOptions.end()) { - out << *p << ((++p != s->jvmOptions.end()) ? " " : "'"); + out << *p; + ++p; + if(p != s->jvmOptions.end()) + { + out << " "; + } + else + { + out << "'"; + } } } } @@ -186,9 +196,19 @@ describe(IceUtil::Output& out, const Ice::CommunicatorPtr& communicator, const S if(!server->options.empty()) { out << nl << "options = '"; - for(Ice::StringSeq::const_iterator p = server->options.begin(); p != server->options.end();) + Ice::StringSeq::const_iterator p = server->options.begin(); + while(p != server->options.end()) { - out << *p << ((++p != server->options.end()) ? " " : "'"); + out << *p; + ++p; + if(p != server->options.end()) + { + out << " "; + } + else + { + out << "'"; + } } } if(!server->envs.empty()) |