diff options
| author | Alan Conway <aconway@apache.org> | 2008-11-19 20:22:38 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2008-11-19 20:22:38 +0000 |
| commit | 35f09d721c0be416bbbda0864d5f2bf6f31639c9 (patch) | |
| tree | 73747fbc5440e56bfcb7dec84a4e020ffcb47061 /qpid/cpp/src/tests/ForkedBroker.h | |
| parent | 3eaeb7ec035df1d532870ed483a770934d41ad8b (diff) | |
| download | qpid-python-35f09d721c0be416bbbda0864d5f2bf6f31639c9.tar.gz | |
tests/failover_soak: run a cluster with clients, kill and restart cluster members, verify client fail-over.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@719055 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/ForkedBroker.h')
| -rw-r--r-- | qpid/cpp/src/tests/ForkedBroker.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/qpid/cpp/src/tests/ForkedBroker.h b/qpid/cpp/src/tests/ForkedBroker.h index c0d72a6235..98235b9690 100644 --- a/qpid/cpp/src/tests/ForkedBroker.h +++ b/qpid/cpp/src/tests/ForkedBroker.h @@ -59,17 +59,23 @@ class ForkedBroker { } void kill(int sig=SIGINT) { - using qpid::ErrnoException; if (pid == 0) return; - if (::kill(pid, sig) < 0) throw ErrnoException("kill failed"); + int savePid = pid; + pid = 0; // Always reset pid, even in case of an exception below. + ::close(pipeFds[1]); + + using qpid::ErrnoException; + if (::kill(savePid, sig) < 0) + throw ErrnoException("kill failed"); int status; - if (::waitpid(pid, &status, 0) < 0) throw ErrnoException("wait for forked process failed"); - if (WEXITSTATUS(status) != 0) - throw qpid::Exception(QPID_MSG("forked broker exited with: " << WEXITSTATUS(status))); - pid = 0; + if (::waitpid(savePid, &status, 0) < 0) + throw ErrnoException("wait for forked process failed"); + if (WEXITSTATUS(status) != 0) + throw qpid::Exception(QPID_MSG("Forked broker exited with: " << WEXITSTATUS(status))); } uint16_t getPort() { return port; } + pid_t getPID() { return pid; } private: @@ -77,7 +83,6 @@ class ForkedBroker { using qpid::ErrnoException; pid = 0; port = 0; - int pipeFds[2]; if(::pipe(pipeFds) < 0) throw ErrnoException("Can't create pipe"); pid = ::fork(); if (pid < 0) throw ErrnoException("Fork failed"); @@ -104,6 +109,7 @@ class ForkedBroker { } } + int pipeFds[2]; pid_t pid; int port; }; |
