From: Brian Aker Date: Wed, 4 Apr 2012 15:49:53 +0000 (-0700) Subject: Use poll, not settimer. X-Git-Tag: 1.0.6~9 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=743312bb2d2f9ed5425670ff29de418182d884e0;p=awesomized%2Flibmemcached Use poll, not settimer. --- diff --git a/libmemcachedutil-1.0/pool.h b/libmemcachedutil-1.0/pool.h index 682aed5f..a11117ca 100644 --- a/libmemcachedutil-1.0/pool.h +++ b/libmemcachedutil-1.0/pool.h @@ -61,8 +61,8 @@ memcached_st* memcached_pool_pop(memcached_pool_st* pool, bool block, memcached_return_t* rc); LIBMEMCACHED_API -memcached_return_t memcached_pool_push(memcached_pool_st* pool, - memcached_st* mmc); + memcached_return_t memcached_pool_push(memcached_pool_st* pool, + memcached_st* mmc); LIBMEMCACHED_API memcached_return_t memcached_pool_release(memcached_pool_st* pool, memcached_st* mmc); diff --git a/tests/libmemcached-1.0/pool.cc b/tests/libmemcached-1.0/pool.cc index f1d01359..10450dac 100644 --- a/tests/libmemcached-1.0/pool.cc +++ b/tests/libmemcached-1.0/pool.cc @@ -53,6 +53,7 @@ using namespace libtest; #include #include +#include #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" @@ -459,27 +460,9 @@ static void *worker_thread(void *ctx) return NULL; } -static void sig_handler(int sig) -{ - switch (sig) - { - case SIGPROF: - set_running(false); - break; - - break; - - default: - Error << __func__ << " caught unknown signal"; - break; - } -} - #define NUM_THREADS 20 test_return_t regression_bug_962815(memcached_st *memc) { - test_skip_valgrind(); - pthread_t pid[NUM_THREADS]; test_false(running()); @@ -493,24 +476,26 @@ test_return_t regression_bug_962815(memcached_st *memc) set_running(true); - struct itimerval new_value; - struct itimerval old_value; - memset(&new_value, 0, sizeof(itimerval)); - memset(&old_value, 0, sizeof(itimerval)); - - new_value.it_interval.tv_sec=0; - new_value.it_interval.tv_usec=10*1000; - new_value.it_value.tv_sec=0; - new_value.it_value.tv_usec=10*1000; - - test_true(signal(SIGPROF, sig_handler) != SIG_ERR); - test_compare(0, setitimer(ITIMER_PROF, &new_value, &old_value)); - for (size_t x=0; x < NUM_THREADS; x++) { test_compare(0, pthread_create(&pid[x], NULL, worker_thread, (void*)pool)); } + { + pollfd fds[1]; + memset(fds, 0, sizeof(pollfd)); + fds[0].fd= -1; //STDIN_FILENO; + fds[0].events= POLLIN; + fds[0].revents= 0; + + int active_fd; + if ((active_fd= poll(fds, 1, 5000)) == -1) + { + Error << "poll() failed with:" << strerror(errno); + } + set_running(false); + } + for (size_t x=0; x < NUM_THREADS; x++) { test_compare(0, pthread_join(pid[x], NULL)); @@ -525,8 +510,6 @@ test_return_t regression_bug_962815(memcached_st *memc) { memcached_free(master); } - test_true(signal(SIGPROF, SIG_DFL) != SIG_ERR); - test_compare(0, setitimer(ITIMER_PROF, &old_value, NULL)); return TEST_SUCCESS; }