From: Brian Aker Date: Wed, 14 Mar 2012 16:54:14 +0000 (-0700) Subject: Update ping call code. X-Git-Tag: 1.0.6~17 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=d2bb5f47f9b0ea0da06c3db435b2d3eca27d92d1;p=awesomized%2Flibmemcached Update ping call code. --- diff --git a/libtest/include.am b/libtest/include.am index accd98ae..f4970642 100644 --- a/libtest/include.am +++ b/libtest/include.am @@ -228,7 +228,9 @@ libtest_skiptest_SOURCES= libtest/skiptest.cc check_PROGRAMS+= libtest/skiptest noinst_PROGRAMS+= libtest/skiptest -libtest_wait_SOURCES= libtest/wait.cc +libtest_wait_SOURCES= +libtest_wait_SOURCES+= libtest/wait.cc +libtest_wait_SOURCES+= libtest/dream.cc noinst_PROGRAMS+= libtest/wait libtest_abort_SOURCES= libtest/abort.cc diff --git a/libtest/server.cc b/libtest/server.cc index b6564b3a..3e891bba 100644 --- a/libtest/server.cc +++ b/libtest/server.cc @@ -198,12 +198,27 @@ bool Server::start() } } - int counter= 0; bool pinged= false; - while ((pinged= ping()) == false and - counter < (is_helgrind() or is_valgrind() ? 20 : 5)) { - dream(counter++, 50000); + uint32_t timeout= 20; // This number should be high enough for valgrind startup (which is slow) + uint32_t waited; + uint32_t this_wait; + uint32_t retry; + + for (waited= 0, retry= 1; ; retry++, waited+= this_wait) + { + if ((pinged= ping()) == true) + { + break; + } + else if (waited >= timeout) + { + break; + } + + this_wait= retry * retry / 3 + 1; + libtest::dream(this_wait, 0); + } } if (pinged == false) diff --git a/libtest/unittest.cc b/libtest/unittest.cc index 0f82a560..a5860bdd 100644 --- a/libtest/unittest.cc +++ b/libtest/unittest.cc @@ -236,8 +236,6 @@ static test_return_t gearmand_cycle_test(void *object) test_skip(true, has_gearmand_binary()); - Error << " " << has_gearmand_binary(); - test_true(server_startup(*servers, "gearmand", get_free_port(), 0, NULL)); return TEST_SUCCESS; diff --git a/libtest/wait.h b/libtest/wait.h index 391afa49..c6c3f966 100644 --- a/libtest/wait.h +++ b/libtest/wait.h @@ -25,6 +25,8 @@ #include #include +#include + namespace libtest { class Wait @@ -57,13 +59,7 @@ public: } this_wait= retry * retry / 3 + 1; - sleep(this_wait); -#ifdef WIN32 - sleep(this_wait); -#else - struct timespec global_sleep_value= { this_wait, 0 }; - nanosleep(&global_sleep_value, NULL); -#endif + libtest::dream(this_wait, 0); } }