8f4dc2986401570ca5474143aa5d0168c53685c0
2 Startup, and shutdown the memcached servers.
5 #define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT+10
11 #include <memcached.h>
15 void server_startup(server_startup_st
*construct
)
19 if ((construct
->server_list
= getenv("MEMCACHED_SERVERS")))
21 printf("servers %s\n", construct
->server_list
);
22 construct
->servers
= memcached_servers_parse(construct
->server_list
);
23 construct
->server_list
= NULL
;
29 char server_string_buffer
[8096];
31 end_ptr
= server_string_buffer
;
33 for (x
= 0; x
< construct
->count
; x
++)
35 char buffer
[1024]; /* Nothing special for number */
39 sprintf(buffer
, "memcached -d -P /tmp/%umemc.pid -U %u", x
, x
+ TEST_PORT_BASE
);
41 sprintf(buffer
, "memcached -d -P /tmp/%umemc.pid -p %u", x
, x
+ TEST_PORT_BASE
);
43 count
= sprintf(end_ptr
, "localhost:%u,", x
+ TEST_PORT_BASE
);
48 construct
->server_list
= strdup(server_string_buffer
);
50 printf("servers %s\n", construct
->server_list
);
51 construct
->servers
= memcached_servers_parse(construct
->server_list
);
54 assert(construct
->servers
);
58 for (x
= 0; x
< memcached_server_list_count(construct
->servers
); x
++)
60 printf("\t%s : %u\n", construct
->servers
[x
].hostname
, construct
->servers
[x
].port
);
61 assert(construct
->servers
[x
].fd
== -1);
62 assert(construct
->servers
[x
].cursor_active
== 0);
68 void server_shutdown(server_startup_st
*construct
)
72 if (construct
->server_list
)
74 for (x
= 0; x
< construct
->count
; x
++)
76 char buffer
[1024]; /* Nothing special for number */
77 sprintf(buffer
, "cat /tmp/%umemc.pid | xargs kill", x
);
80 sprintf(buffer
, "/tmp/%umemc.pid", x
);
84 free(construct
->server_list
);