#include "Server.hpp"
-#include "Connection.hpp"
+#include "Retry.hpp"
#include "ForkAndExec.hpp"
#include <sys/wait.h>
}
Malloced stat(memcached_stat(*memc, nullptr, nullptr));
- if (!*stat || !stat->pid) {
+ if (!*stat || !stat->pid || stat->pid == -1) {
return false;
}
if (stat->pid != pid) {
return true;
}
+bool Server::ensureListening() {
+ return Retry{[this] {
+ again:
+ start();
+ if (!isListening()) {
+ if (tryWait()){
+ goto again;
+ }
+ }
+ return isListening();
+ }}();
+}
+
bool Server::stop() {
if (!pid) {
return true;