pgpool2.git / summary / log / commit / refs

commit    f6d44b62bef9ebf67c30ed44c4c8adbcb4dfebe9
Author:   Tatsuo Ishii <ishii@postgresql.org>
Date:     Fri Nov 18 04:17:42 2011 +0000

    Fix pool_get_memqcache_stats(). When on memory cache is not enabled,
    do not look into shared memory stats info. In this case, all 0
    POOL_QUERY_CACHE_STATS returned.


pool_memqcache.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pool_memqcache.c b/pool_memqcache.c index e198af705..a77dc660c 100644 --- a/pool_memqcache.c +++ b/pool_memqcache.c @@ -2618,9 +2618,14 @@ POOL_QUERY_CACHE_STATS *pool_get_memqcache_stats(void) { static POOL_QUERY_CACHE_STATS mystats; - pool_semaphore_lock(QUERY_CACHE_STATS_SEM); - memcpy(&mystats, stats, sizeof(POOL_QUERY_CACHE_STATS)); - pool_semaphore_unlock(QUERY_CACHE_STATS_SEM); + memset(&mystats, 0, sizeof(POOL_QUERY_CACHE_STATS)); + + if (stats) + { + pool_semaphore_lock(QUERY_CACHE_STATS_SEM); + memcpy(&mystats, stats, sizeof(POOL_QUERY_CACHE_STATS)); + pool_semaphore_unlock(QUERY_CACHE_STATS_SEM); + } return &mystats; } [parent: d5040f5cfa92]