- server_st *server= NULL;
-
- {
- char *var;
- char variable_buffer[1024];
-
- snprintf(variable_buffer, sizeof(variable_buffer), "LIBMEMCACHED_PORT_%u", x);
-
- if ((var= getenv(variable_buffer)))
- {
- server= new server_st((in_port_t)atoi(var), __getpid, __ping);
- }
- else
- {
- server= new server_st(in_port_t(x +TEST_PORT_BASE +port_base), __getpid, __ping);
-
- while (not cycle_server(server))
- {
- std::cerr << CERR_PREFIX << "Found server " << *server << ", could not flush it, so trying next port." << std::endl;
- port_base++;
- server->set_port(in_port_t(x +TEST_PORT_BASE +port_base));
- }
- }
- }
-
- if (server->is_used())
- {
- std::cerr << std::endl << "Using server at : " << server << std::endl;
- }
- else
- {
- char buffer[FILENAME_MAX];
- if (x == 0)
- {
- snprintf(buffer, sizeof(buffer), "%s -d -t 1 -p %u -U %u -m 128",
- MEMCACHED_BINARY, server->port(), server->port());
- }
- else
- {
- snprintf(buffer, sizeof(buffer), "%s -d -t 1 -p %u -U %u",
- MEMCACHED_BINARY, server->port(), server->port());
- }
- server->set_command(buffer);
-
- if (not server->start())
- {
- std::cerr << CERR_PREFIX << "Failed system(" << buffer << ")" << std::endl;
- delete server;
- return false;
- }
- std::cerr << "STARTING SERVER: " << buffer << " pid:" << server->pid() << std::endl;
- }
- construct->push_server(server);
-
- if (x == 0)
- {
- assert(server->has_port());
- set_default_port(server->port());
- }
-
- char port_str[NI_MAXSERV];
- snprintf(port_str, sizeof(port_str), "%u", int(server->port()));
-
- server_config_string+= "--server=";
- server_config_string+= server->hostname();
- server_config_string+= ":";
- server_config_string+= port_str;
- server_config_string+= " ";