pgpool2.git / summary / log / commit / refs
commit a45aa3011ae15e2dc55c65b88ba8ebf5a7b35d4d
Author: Tatsuo Ishii <ishii@sraoss.co.jp>
Date: Wed Aug 09 02:10:28 2023 +0000
Fix covery warning.
Fix query cache module assigned time_t value to int32 variable. Change
the variable type to int64. Per Coverity. Also use difftime() to
calculate time_t difference. This is a recommended practice.
https://www.jpcert.or.jp/sc-rules/c-msc05-c.html
src/include/query_cache/pool_memqcache.h | 2 +-
src/query_cache/pool_memqcache.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/include/query_cache/pool_memqcache.h b/src/include/query_cache/pool_memqcache.h
index 4622c96a0..9fc3e6a7a 100644
--- a/src/include/query_cache/pool_memqcache.h
+++ b/src/include/query_cache/pool_memqcache.h
@@ -110,7 +110,7 @@ typedef struct
{
unsigned int total_length; /* total length in bytes including myself */
time_t timestamp; /* cache creation time */
- int expire; /* cache expire duration in seconds */
+ int64 expire; /* cache expire duration in seconds */
} POOL_CACHE_ITEM_HEADER;
typedef struct
diff --git a/src/query_cache/pool_memqcache.c b/src/query_cache/pool_memqcache.c
index c1ae800d8..241763feb 100644
--- a/src/query_cache/pool_memqcache.c
+++ b/src/query_cache/pool_memqcache.c
@@ -2732,7 +2732,7 @@ static POOL_CACHEID * pool_find_item_on_shmem_cache(POOL_QUERY_HASH * query_hash
if (cih->expire > 0)
{
now = time(NULL);
- if (now > (cih->timestamp + cih->expire))
+ if (difftime(now, cih->timestamp) > cih->expire)
{
/*
* We need to acquire an exclusive lock before removing the cache
[parent: 7db55fa23dec]