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
;
30 char server_string_buffer
[8096];
32 end_ptr
= server_string_buffer
;
34 for (x
= 0; x
< construct
->count
; x
++)
36 char buffer
[1024]; /* Nothing special for number */
40 sprintf(buffer
, "memcached -d -P /tmp/%umemc.pid -U %u", x
, x
+ TEST_PORT_BASE
);
42 sprintf(buffer
, "memcached -d -P /tmp/%umemc.pid -p %u", x
, x
+ TEST_PORT_BASE
);
44 count
= sprintf(end_ptr
, "localhost:%u,", x
+ TEST_PORT_BASE
);
49 construct
->server_list
= strdup(server_string_buffer
);
51 printf("servers %s\n", construct
->server_list
);
52 construct
->servers
= memcached_servers_parse(construct
->server_list
);
55 assert(construct
->servers
);
59 for (x
= 0; x
< memcached_server_list_count(construct
->servers
); x
++)
61 printf("\t%s : %u\n", construct
->servers
[x
].hostname
, construct
->servers
[x
].port
);
62 assert(construct
->servers
[x
].fd
== -1);
63 assert(construct
->servers
[x
].cursor_active
== 0);
69 void server_shutdown(server_startup_st
*construct
)
73 if (construct
->server_list
)
75 for (x
= 0; x
< construct
->count
; x
++)
77 char buffer
[1024]; /* Nothing special for number */
78 sprintf(buffer
, "cat /tmp/%umemc.pid | xargs kill", x
);
81 sprintf(buffer
, "/tmp/%umemc.pid", x
);
85 free(construct
->server_list
);