summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/Activator.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2010-02-19 18:45:14 +0100
committerBenoit Foucher <benoit@zeroc.com>2010-02-19 18:45:14 +0100
commitea9a8bcfc079175205766491ab217e65536a656f (patch)
tree8dd6cd069f9966bd59d72587052a42195d45cf63 /cpp/src/IceGrid/Activator.cpp
parentadded txt to ICE_LICENSE (diff)
downloadice-ea9a8bcfc079175205766491ab217e65536a656f.tar.bz2
ice-ea9a8bcfc079175205766491ab217e65536a656f.tar.xz
ice-ea9a8bcfc079175205766491ab217e65536a656f.zip
Fixed bug 4677 - IceGrid update hang
Diffstat (limited to 'cpp/src/IceGrid/Activator.cpp')
-rw-r--r--cpp/src/IceGrid/Activator.cpp63
1 files changed, 36 insertions, 27 deletions
diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp
index 1f3e3e01f30..020e8ab5548 100644
--- a/cpp/src/IceGrid/Activator.cpp
+++ b/cpp/src/IceGrid/Activator.cpp
@@ -1371,44 +1371,53 @@ Activator::setInterrupt()
int
Activator::waitPid(pid_t processPid)
{
- int status;
-#if defined(__linux)
- int nRetry = 0;
- while(true) // The while loop is necessary for the linux workaround.
+ try
{
- pid_t pid = waitpid(processPid, &status, 0);
- if(pid < 0)
+ int status;
+#if defined(__linux)
+ int nRetry = 0;
+ while(true) // The while loop is necessary for the linux workaround.
{
- //
- // Some Linux distribution have a bogus waitpid() (e.g.: CentOS 4.x). It doesn't
- // block and reports an incorrect ECHILD error on the first call. We sleep a
- // little and retry to work around this issue (it appears from testing that a
- // single retry is enough but to make sure we retry up to 10 times before to throw.)
- //
- if(errno == ECHILD && nRetry < 10)
+ pid_t pid = waitpid(processPid, &status, 0);
+ if(pid < 0)
{
- // Wait 1ms, 11ms, 21ms, etc.
- IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(nRetry * 10 + 1));
- ++nRetry;
- continue;
+ //
+ // Some Linux distribution have a bogus waitpid() (e.g.: CentOS 4.x). It doesn't
+ // block and reports an incorrect ECHILD error on the first call. We sleep a
+ // little and retry to work around this issue (it appears from testing that a
+ // single retry is enough but to make sure we retry up to 10 times before to throw.)
+ //
+ if(errno == ECHILD && nRetry < 10)
+ {
+ // Wait 1ms, 11ms, 21ms, etc.
+ IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(nRetry * 10 + 1));
+ ++nRetry;
+ continue;
+ }
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
+ assert(pid == processPid);
+ break;
+ }
+#else
+ pid_t pid = waitpid(processPid, &status, 0);
+ if(pid < 0)
+ {
SyscallException ex(__FILE__, __LINE__);
ex.error = getSystemErrno();
throw ex;
}
assert(pid == processPid);
- break;
+#endif
+ return status;
}
-#else
- pid_t pid = waitpid(processPid, &status, 0);
- if(pid < 0)
+ catch(const Ice::LocalException& ex)
{
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ Error out(_traceLevels->logger);
+ out << "unable to get process status:\n" << ex;
+ return -1;
}
- assert(pid == processPid);
-#endif
- return status;
}
#endif