pgpool2.git / summary / log / commit / refs

commit    e48e96f4b7b4905dba8b6e81ef404e23f45b049b
Author:   Tatsuo Ishii <ishii@postgresql.org>
Date:     Thu Nov 24 07:28:12 2011 +0000

    Fix pool_add_item_shmem_cache so that it undo the cache entry addition
    when pool_hash_insert failed to insert hash entry.


pool_memqcache.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pool_memqcache.c b/pool_memqcache.c index a77dc660c..deffc7f0e 100644 --- a/pool_memqcache.c +++ b/pool_memqcache.c @@ -1712,7 +1712,16 @@ static POOL_CACHEID *pool_add_item_shmem_cache(POOL_QUERY_HASH *query_hash, char bh->num_items++; /* Update hash table */ - pool_hash_insert(query_hash, &cacheid, false); + if (pool_hash_insert(query_hash, &cacheid, false) < 0) + { + pool_error("pool_add_item_shmem_cache: pool_hash_insert failed"); + + /* Since we have failed to insert hash index entry, we need to + * undo the addition of cache entry. + */ + pool_delete_item_shmem_cache(&cacheid); + return NULL; + } #ifdef SHMEMCACHE_DEBUG dump_shmem_cache(blockid); [parent: ebbf0da76458]