projects
/
m6w6
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
WIP
[m6w6/libmemcached]
/
test
/
lib
/
Server.cpp
diff --git
a/test/lib/Server.cpp
b/test/lib/Server.cpp
index af6e41ba63d5a1f010f3c9ca0de0aef13bd2d989..cf520094029949cb94b0ac7d9d61087858370f04 100644
(file)
--- a/
test/lib/Server.cpp
+++ b/
test/lib/Server.cpp
@@
-3,7
+3,9
@@
#include "ForkAndExec.hpp"
#include <sys/wait.h>
#include "ForkAndExec.hpp"
#include <sys/wait.h>
-#include <unistd.h>
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
Server::Server(string binary_, Server::argv_t args_)
: binary{move(binary_)}
Server::Server(string binary_, Server::argv_t args_)
: binary{move(binary_)}
@@
-67,7
+69,8
@@
vector<char *> Server::createArgv() {
vector<char *> arr;
pushArg(arr, binary);
vector<char *> arr;
pushArg(arr, binary);
- //pushArg(arr, "-v");
+ pushArg(arr, "-u");
+ pushArg(arr, "nobody");
for (auto it = args.cbegin(); it != args.cend(); ++it) {
if (holds_alternative<arg_t>(*it)) {
for (auto it = args.cbegin(); it != args.cend(); ++it) {
if (holds_alternative<arg_t>(*it)) {
@@
-116,7
+119,7
@@
optional<Server::ChildProc> Server::start() {
return ChildProc{pid, pipe};
}
return ChildProc{pid, pipe};
}
-bool Server::isListening() {
+bool Server::isListening()
const
{
MemcachedPtr memc;
if (holds_alternative<string>(socket_or_port)) {
MemcachedPtr memc;
if (holds_alternative<string>(socket_or_port)) {
@@
-148,11
+151,16
@@
bool Server::isListening() {
}
bool Server::ensureListening() {
}
bool Server::ensureListening() {
+ if (!start()) {
+ return false;
+ }
return Retry{[this] {
again:
start();
if (!isListening()) {
return Retry{[this] {
again:
start();
if (!isListening()) {
- if (tryWait()){
+ auto old = pid;
+ if (tryWait()) {
+ cerr << "Collected zombie " << *this << "(old pid=" << old << ")\n";
goto again;
}
}
goto again;
}
}
@@
-185,7
+193,8
@@
bool Server::check() {
bool Server::wait(int flags) {
if (pid && pid == waitpid(pid, &status, flags)) {
bool Server::wait(int flags) {
if (pid && pid == waitpid(pid, &status, flags)) {
- if (drain().length() && output != "Signal handled: Terminated.\n") {
+ if (drain().length() &&
+ output.rfind("Signal handled: Terminated", 0) != 0) {
cerr << "Output of " << *this << ":\n";
istringstream iss{output};
cerr << "Output of " << *this << ":\n";
istringstream iss{output};