- unlink(pid_file().c_str());
- }
-
- if (broken_socket_cleanup() and has_socket() and not socket().empty())
- {
- unlink(socket().c_str());
- }
-
- reset_pid();
-
- return true;
- }
-
- return false;
-}
-
-void server_startup_st::push_server(Server *arg)
-{
- servers.push_back(arg);
-
- char port_str[NI_MAXSERV];
- snprintf(port_str, sizeof(port_str), "%u", int(arg->port()));
-
- std::string server_config_string;
- if (arg->has_socket())
- {
- server_config_string+= "--socket=";
- server_config_string+= '"';
- server_config_string+= arg->socket();
- server_config_string+= '"';
- server_config_string+= " ";
- }
- else
- {
- server_config_string+= "--server=";
- server_config_string+= arg->hostname();
- server_config_string+= ":";
- server_config_string+= port_str;
- server_config_string+= " ";
- }
-
- server_list+= server_config_string;
-
-}
-
-Server* server_startup_st::pop_server()
-{
- Server *tmp= servers.back();
- servers.pop_back();
- return tmp;
-}
-
-void server_startup_st::shutdown(bool remove)
-{
- if (remove)
- {
- for (std::vector<Server *>::iterator iter= servers.begin(); iter != servers.end(); iter++)
- {
- delete *iter;
- }
- servers.clear();
- }
- else
- {
- for (std::vector<Server *>::iterator iter= servers.begin(); iter != servers.end(); iter++)
- {
- if ((*iter)->has_pid() and not (*iter)->kill((*iter)->pid()))
- {
- Error << "Unable to kill:" << *(*iter);
- }
- }
- }
-}
-
-server_startup_st::~server_startup_st()
-{
- shutdown(true);
-}
-
-bool server_startup_st::is_debug() const
-{
- return bool(getenv("LIBTEST_MANUAL_GDB"));
-}
-
-bool server_startup_st::is_valgrind() const
-{
- return bool(getenv("LIBTEST_MANUAL_VALGRIND"));
-}
-
-bool server_startup_st::is_helgrind() const
-{
- return bool(getenv("LIBTEST_MANUAL_HELGRIND"));
-}
-
-
-bool server_startup(server_startup_st& construct, const std::string& server_type, in_port_t try_port, int argc, const char *argv[])
-{
- Outn();
- (void)try_port;
-
- // Look to see if we are being provided ports to use
- {
- char variable_buffer[1024];
- snprintf(variable_buffer, sizeof(variable_buffer), "LIBTEST_PORT_%lu", (unsigned long)construct.count());
-
- char *var;
- if ((var= getenv(variable_buffer)))
- {
- in_port_t tmp= in_port_t(atoi(var));
-
- if (tmp > 0)
- try_port= tmp;
- }
- }
-
- libtest::Server *server= NULL;
- if (0)
- { }
- else if (server_type.compare("gearmand") == 0)
- {
- if (GEARMAND_BINARY)
- {
- if (HAVE_LIBGEARMAN)
- {
- server= build_gearmand("localhost", try_port);
- }
- else
- {
- Error << "Libgearman was not found";
- }
- }
- else
- {
- Error << "No gearmand binary is available";
- }
- }
- else if (server_type.compare("blobslap_worker") == 0)
- {
- if (GEARMAND_BINARY and GEARMAND_BLOBSLAP_WORKER)
- {
- if (HAVE_LIBGEARMAN)
- {
- server= build_blobslap_worker(try_port);
- }
- else
- {
- Error << "Libgearman was not found";
- }
- }
- else
- {
- Error << "No gearmand binary is available";
- }
- }
- else if (server_type.compare("memcached-sasl") == 0)
- {
- if (MEMCACHED_SASL_BINARY)
- {
- if (HAVE_LIBMEMCACHED)