5023188c0dd088e533aa27e5b2ee60b4c8828d68
2 Startup, and shutdown the memcached servers.
5 #define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT+10
12 #include <libmemcached/memcached.h>
14 #include "libmemcached/libmemcached_config.h"
17 void server_startup(server_startup_st
*construct
)
21 if ((construct
->server_list
= getenv("MEMCACHED_SERVERS")))
23 printf("servers %s\n", construct
->server_list
);
24 construct
->servers
= memcached_servers_parse(construct
->server_list
);
25 construct
->server_list
= NULL
;
31 char server_string_buffer
[8096];
33 end_ptr
= server_string_buffer
;
35 for (x
= 0; x
< construct
->count
; x
++)
37 char buffer
[1024]; /* Nothing special for number */
43 sprintf(buffer
, "%s -d -P /tmp/%umemc.pid -t 1 -U %u -m 128",
44 MEMCACHED_BINARY
, x
, x
+ TEST_PORT_BASE
);
46 sprintf(buffer
, "%s -d -P /tmp/%umemc.pid -t 1 -U %u",
47 MEMCACHED_BINARY
, x
, x
+ TEST_PORT_BASE
);
52 sprintf(buffer
, "%s -d -P /tmp/%umemc.pid -t 1 -p %u -m 128",
53 MEMCACHED_BINARY
, x
, x
+ TEST_PORT_BASE
);
55 sprintf(buffer
, "%s -d -P /tmp/%umemc.pid -t 1 -p %u",
56 MEMCACHED_BINARY
, x
, x
+ TEST_PORT_BASE
);
59 status
= system(buffer
);
60 count
= sprintf(end_ptr
, "localhost:%u,", x
+ TEST_PORT_BASE
);
65 construct
->server_list
= strdup(server_string_buffer
);
67 printf("servers %s\n", construct
->server_list
);
68 construct
->servers
= memcached_servers_parse(construct
->server_list
);
71 assert(construct
->servers
);
75 for (x
= 0; x
< memcached_server_list_count(construct
->servers
); x
++)
77 printf("\t%s : %u\n", construct
->servers
[x
].hostname
, construct
->servers
[x
].port
);
78 assert(construct
->servers
[x
].fd
== -1);
79 assert(construct
->servers
[x
].cursor_active
== 0);
85 void server_shutdown(server_startup_st
*construct
)
89 if (construct
->server_list
)
91 for (x
= 0; x
< construct
->count
; x
++)
93 char buffer
[1024]; /* Nothing special for number */
94 sprintf(buffer
, "cat /tmp/%umemc.pid | xargs kill", x
);
97 sprintf(buffer
, "/tmp/%umemc.pid", x
);
101 free(construct
->server_list
);