From 400788eac8cccf9c30a616129a5dc2d67780790f Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Tue, 15 Sep 2020 14:01:10 +0200 Subject: [PATCH] testing: check for pid in lib/Server::isListening() --- testing/lib/Server.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/testing/lib/Server.cpp b/testing/lib/Server.cpp index 481a9fd6..2ab4d5b7 100644 --- a/testing/lib/Server.cpp +++ b/testing/lib/Server.cpp @@ -110,12 +110,24 @@ optional Server::start() { } bool Server::isListening() { - Connection conn(socket_or_port); + MemcachedPtr memc; - if (!conn.open()) { + if (holds_alternative(socket_or_port)) { + if (memcached_server_add_unix_socket(*memc, get(socket_or_port).c_str())) { + return false; + } + } else { + if (memcached_server_add(*memc, "localhost", get(socket_or_port))) { + return false; + } + } + + Malloced stat(memcached_stat(*memc, nullptr, nullptr)); + if (!*stat || !stat->pid || stat->pid != pid) { return false; } - return conn.isOpen(); + + return true; } bool Server::stop() { -- 2.30.2