From: Michael Wallner Date: Tue, 15 Sep 2020 12:01:10 +0000 (+0200) Subject: testing: check for pid in lib/Server::isListening() X-Git-Tag: 1.1.0-beta1~236^2~65 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=400788eac8cccf9c30a616129a5dc2d67780790f;p=m6w6%2Flibmemcached testing: check for pid in lib/Server::isListening() --- 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() {