pgpool2.git / summary / log / commit / refs

commit    f2ae085422b37fde8cf357517df286c71e9e041a
Author:   Tatsuo Ishii <ishii@sraoss.co.jp>
Date:     Wed Jan 13 09:49:51 2021 +0000

    Fix error while allocating shared memory.
    
    If num_init_children * max_pool is huge, pool_coninfo_size() failed to
    calculate the size of required shared memory because the data type
    used for the variable to store shared memory size was int and it
    overflows for too large shared memory size. To fix this change
    pool_coninfo_size() to size_t and use appropriate size_t for the
    variable used within the function.
    
    Also fix to use proper format qualifier in
    pool_shared_memory_create().


src/context/pool_process_context.c | 8 ++++---- src/include/context/pool_process_context.h | 4 ++-- src/utils/pool_shmem.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/context/pool_process_context.c b/src/context/pool_process_context.c index 4a5abd8f3..6e6402cfa 100644 --- a/src/context/pool_process_context.c +++ b/src/context/pool_process_context.c @@ -6,7 +6,7 @@ * pgpool: a language independent connection pool server for PostgreSQL * written by Tatsuo Ishii * - * Copyright (c) 2003-2017 PgPool Global Development Group + * Copyright (c) 2003-2021 PgPool Global Development Group * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby @@ -105,10 +105,10 @@ pool_increment_local_session_id(void) /* * Return byte size of connection info(ConnectionInfo) on shmem. */ -int +size_t pool_coninfo_size(void) { - int size; + size_t size; size = pool_config->num_init_children * pool_config->max_pool * @@ -116,7 +116,7 @@ pool_coninfo_size(void) sizeof(ConnectionInfo); ereport(DEBUG1, - (errmsg("pool_coninfo_size: num_init_children (%d) * max_pool (%d) * MAX_NUM_BACKENDS (%d) * sizeof(ConnectionInfo) (%zu) = %d bytes requested for shared memory", + (errmsg("pool_coninfo_size: num_init_children (%d) * max_pool (%d) * MAX_NUM_BACKENDS (%d) * sizeof(ConnectionInfo) (%zu) = %zu bytes requested for shared memory", pool_config->num_init_children, pool_config->max_pool, MAX_NUM_BACKENDS, diff --git a/src/include/context/pool_process_context.h b/src/include/context/pool_process_context.h index 35f3a3113..a9f9e1002 100644 --- a/src/include/context/pool_process_context.h +++ b/src/include/context/pool_process_context.h @@ -6,7 +6,7 @@ * pgpool: a language independent connection pool server for PostgreSQL * written by Tatsuo Ishii * - * Copyright (c) 2003-2015 PgPool Global Development Group + * Copyright (c) 2003-2021 PgPool Global Development Group * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby @@ -63,7 +63,7 @@ extern void pool_init_process_context(void); extern POOL_PROCESS_CONTEXT * pool_get_process_context(void); extern ProcessInfo * pool_get_my_process_info(void); extern void pool_increment_local_session_id(void); -extern int pool_coninfo_size(void); +extern size_t pool_coninfo_size(void); extern int pool_coninfo_num(void); extern ConnectionInfo * pool_coninfo(int child, int connection_pool, int backend); extern ConnectionInfo * pool_coninfo_pid(int pid, int connection_pool, int backend); diff --git a/src/utils/pool_shmem.c b/src/utils/pool_shmem.c index 687104270..077266169 100644 --- a/src/utils/pool_shmem.c +++ b/src/utils/pool_shmem.c @@ -5,7 +5,7 @@ * pgpool: a language independent connection pool server for PostgreSQL * written by Tatsuo Ishii * - * Portions Copyright (c) 2003-2011, PgPool Global Development Group + * Portions Copyright (c) 2003-2021, PgPool Global Development Group * Portions Copyright (c) 2003-2004, PostgreSQL Global Development Group * * Permission to use, copy, modify, and distribute this software and @@ -109,7 +109,7 @@ pool_shared_memory_create(size_t size) if (shmid < 0) ereport(FATAL, - (errmsg("could not create shared memory for request size: %ld", size), + (errmsg("could not create shared memory for request size: %zu", size), errdetail("shared memory creation failed with error \"%m\""))); /* Register on-exit routine to delete the new segment */ [parent: 409f5f5648e4]