From: Brian Aker Date: Fri, 16 Jul 2010 19:24:58 +0000 (-0700) Subject: Verify that servers have started up by reading their pid file. X-Git-Tag: 0.44~20 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=6be7286b5a5ecc708ac8778be1d4532b37c2330c;p=m6w6%2Flibmemcached Verify that servers have started up by reading their pid file. --- diff --git a/tests/server.c b/tests/server.c index 58a9d276..c0521e5b 100644 --- a/tests/server.c +++ b/tests/server.c @@ -26,6 +26,8 @@ #include #include #include +#include + #include "server.h" void server_startup(server_startup_st *construct) @@ -93,6 +95,39 @@ void server_startup(server_startup_st *construct) } *end_ptr= 0; + for (uint32_t x= 0; x < construct->count; x++) + { + uint32_t counter= 3; + char buffer[1024]; /* Nothing special for number */ + + snprintf(buffer, sizeof(buffer), "/tmp/%umemc.pid", x); + + while (--counter) + { + int memcached_pid; + + FILE *file; + file= fopen(buffer, "r"); + if (file == NULL) + { + struct timespec req= { .tv_sec= 0, .tv_nsec= 5000 }; + nanosleep(&req, NULL); + + continue; + } + char *found= fgets(buffer, sizeof(buffer), file); + if (!found) + { + abort(); + } + // Yes, we currently pitch this and don't make use of it. + memcached_pid= atoi(buffer); + fclose(file); + } + + + } + construct->server_list= strdup(server_string_buffer); } printf("servers %s\n", construct->server_list);