From 8b3ab8f74fe7cfc45f6e97b0f702210afada776d Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Thu, 4 Apr 2024 01:29:33 +0700 Subject: [PATCH] Rename redisAtomic to serverAtomic (#180) https://github.com/valkey-io/valkey/issues/144 Signed-off-by: 0del --- src/atomicvar.h | 8 ++++---- src/lazyfree.c | 4 ++-- src/networking.c | 2 +- src/redis-benchmark.c | 14 +++++++------- src/server.h | 26 +++++++++++++------------- src/threads_mngr.c | 4 ++-- src/zmalloc.c | 2 +- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/atomicvar.h b/src/atomicvar.h index bcabdccc5..b506c5d29 100644 --- a/src/atomicvar.h +++ b/src/atomicvar.h @@ -80,8 +80,8 @@ #ifndef __ATOMIC_VAR_H #define __ATOMIC_VAR_H -/* Define redisAtomic for atomic variable. */ -#define redisAtomic +/* Define serverAtomic for atomic variable. */ +#define serverAtomic /* To test Redis with Helgrind (a Valgrind tool) it is useful to define * the following macro, so that __sync macros are used: those can be detected @@ -109,8 +109,8 @@ #if !defined(__ATOMIC_VAR_FORCE_SYNC_MACROS) && defined(__STDC_VERSION__) && \ (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__) /* Use '_Atomic' keyword if the compiler supports. */ -#undef redisAtomic -#define redisAtomic _Atomic +#undef serverAtomic +#define serverAtomic _Atomic /* Implementation using _Atomic in C11. */ #include diff --git a/src/lazyfree.c b/src/lazyfree.c index cd220fca1..4733d8f99 100644 --- a/src/lazyfree.c +++ b/src/lazyfree.c @@ -4,8 +4,8 @@ #include "functions.h" #include "cluster.h" -static redisAtomic size_t lazyfree_objects = 0; -static redisAtomic size_t lazyfreed_objects = 0; +static serverAtomic size_t lazyfree_objects = 0; +static serverAtomic size_t lazyfreed_objects = 0; /* Release objects from the lazyfree thread. It's just decrRefCount() * updating the count of objects to release. */ diff --git a/src/networking.c b/src/networking.c index e979e2ecc..5bb7706e7 100644 --- a/src/networking.c +++ b/src/networking.c @@ -4195,7 +4195,7 @@ void processEventsWhileBlocked(void) { #endif typedef struct __attribute__((aligned(CACHE_LINE_SIZE))) threads_pending { - redisAtomic unsigned long value; + serverAtomic unsigned long value; } threads_pending; pthread_t io_threads[IO_THREADS_MAX_NUM]; diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c index f1cc39a7e..48d178109 100644 --- a/src/redis-benchmark.c +++ b/src/redis-benchmark.c @@ -85,11 +85,11 @@ static struct config { int tls; struct cliSSLconfig sslconfig; int numclients; - redisAtomic int liveclients; + serverAtomic int liveclients; int requests; - redisAtomic int requests_issued; - redisAtomic int requests_finished; - redisAtomic int previous_requests_finished; + serverAtomic int requests_issued; + serverAtomic int requests_finished; + serverAtomic int previous_requests_finished; int last_printed_bytes; long long previous_tick; int keysize; @@ -118,9 +118,9 @@ static struct config { struct redisConfig *redis_config; struct hdr_histogram* latency_histogram; struct hdr_histogram* current_sec_latency_histogram; - redisAtomic int is_fetching_slots; - redisAtomic int is_updating_slots; - redisAtomic int slots_last_update; + serverAtomic int is_fetching_slots; + serverAtomic int is_updating_slots; + serverAtomic int slots_last_update; int enable_tracking; pthread_mutex_t liveclients_mutex; pthread_mutex_t is_updating_slots_mutex; diff --git a/src/server.h b/src/server.h index 07dd1485d..4226bd99d 100644 --- a/src/server.h +++ b/src/server.h @@ -1594,7 +1594,7 @@ struct redisServer { int module_pipe[2]; /* Pipe used to awake the event loop by module threads. */ pid_t child_pid; /* PID of current child */ int child_type; /* Type of current child */ - redisAtomic int module_gil_acquring; /* Indicates whether the GIL is being acquiring by the main thread. */ + serverAtomic int module_gil_acquring; /* Indicates whether the GIL is being acquiring by the main thread. */ /* Networking */ int port; /* TCP listening port */ int tls_port; /* TLS listening port */ @@ -1633,7 +1633,7 @@ struct redisServer { pause_event client_pause_per_purpose[NUM_PAUSE_PURPOSES]; char neterr[ANET_ERR_LEN]; /* Error buffer for anet.c */ dict *migrate_cached_sockets;/* MIGRATE cached sockets */ - redisAtomic uint64_t next_client_id; /* Next client unique ID. Incremental. */ + serverAtomic uint64_t next_client_id; /* Next client unique ID. Incremental. */ int protected_mode; /* Don't accept external connections. */ int io_threads_num; /* Number of IO threads to use. */ int io_threads_do_reads; /* Read and parse from IO threads? */ @@ -1689,10 +1689,10 @@ struct redisServer { long long slowlog_log_slower_than; /* SLOWLOG time limit (to get logged) */ unsigned long slowlog_max_len; /* SLOWLOG max number of items logged */ struct malloc_stats cron_malloc_stats; /* sampled in serverCron(). */ - redisAtomic long long stat_net_input_bytes; /* Bytes read from network. */ - redisAtomic long long stat_net_output_bytes; /* Bytes written to network. */ - redisAtomic long long stat_net_repl_input_bytes; /* Bytes read during replication, added to stat_net_input_bytes in 'info'. */ - redisAtomic long long stat_net_repl_output_bytes; /* Bytes written during replication, added to stat_net_output_bytes in 'info'. */ + serverAtomic long long stat_net_input_bytes; /* Bytes read from network. */ + serverAtomic long long stat_net_output_bytes; /* Bytes written to network. */ + serverAtomic long long stat_net_repl_input_bytes; /* Bytes read during replication, added to stat_net_input_bytes in 'info'. */ + serverAtomic long long stat_net_repl_output_bytes; /* Bytes written during replication, added to stat_net_output_bytes in 'info'. */ size_t stat_current_cow_peak; /* Peak size of copy on write bytes. */ size_t stat_current_cow_bytes; /* Copy on write bytes while child is active. */ monotime stat_current_cow_updated; /* Last update time of stat_current_cow_bytes */ @@ -1709,9 +1709,9 @@ struct redisServer { long long stat_dump_payload_sanitizations; /* Number deep dump payloads integrity validations. */ long long stat_io_reads_processed; /* Number of read events processed by IO / Main threads */ long long stat_io_writes_processed; /* Number of write events processed by IO / Main threads */ - redisAtomic long long stat_total_reads_processed; /* Total number of read events processed */ - redisAtomic long long stat_total_writes_processed; /* Total number of write events processed */ - redisAtomic long long stat_client_qbuf_limit_disconnections; /* Total number of clients reached query buf length limit */ + serverAtomic long long stat_total_reads_processed; /* Total number of read events processed */ + serverAtomic long long stat_total_writes_processed; /* Total number of write events processed */ + serverAtomic long long stat_client_qbuf_limit_disconnections; /* Total number of clients reached query buf length limit */ long long stat_client_outbuf_limit_disconnections; /* Total number of clients reached output buf length limit */ /* The following two are used to track instantaneous metrics, like * number of operations per second, network traffic. */ @@ -1800,8 +1800,8 @@ struct redisServer { int aof_last_write_errno; /* Valid if aof write/fsync status is ERR */ int aof_load_truncated; /* Don't stop on unexpected AOF EOF. */ int aof_use_rdb_preamble; /* Specify base AOF to use RDB encoding on AOF rewrites. */ - redisAtomic int aof_bio_fsync_status; /* Status of AOF fsync in bio job. */ - redisAtomic int aof_bio_fsync_errno; /* Errno of AOF fsync in bio job. */ + serverAtomic int aof_bio_fsync_status; /* Status of AOF fsync in bio job. */ + serverAtomic int aof_bio_fsync_errno; /* Errno of AOF fsync in bio job. */ aofManifest *aof_manifest; /* Used to track AOFs. */ int aof_disable_auto_gc; /* If disable automatically deleting HISTORY type AOFs? default no. (for testings). */ @@ -1866,7 +1866,7 @@ struct redisServer { char replid2[CONFIG_RUN_ID_SIZE+1]; /* replid inherited from master*/ long long master_repl_offset; /* My current replication offset */ long long second_replid_offset; /* Accept offsets up to this for replid2. */ - redisAtomic long long fsynced_reploff_pending;/* Largest replication offset to + serverAtomic long long fsynced_reploff_pending;/* Largest replication offset to * potentially have been fsynced, applied to fsynced_reploff only when AOF state is AOF_ON (not during the initial rewrite) */ @@ -1974,7 +1974,7 @@ struct redisServer { int list_max_listpack_size; int list_compress_depth; /* time cache */ - redisAtomic time_t unixtime; /* Unix time sampled every cron cycle. */ + serverAtomic time_t unixtime; /* Unix time sampled every cron cycle. */ time_t timezone; /* Cached timezone. As set by tzset(). */ int daylight_active; /* Currently in daylight saving time. */ mstime_t mstime; /* 'unixtime' in milliseconds. */ diff --git a/src/threads_mngr.c b/src/threads_mngr.c index 01080c822..2d71ffacd 100644 --- a/src/threads_mngr.c +++ b/src/threads_mngr.c @@ -46,10 +46,10 @@ static const clock_t RUN_ON_THREADS_TIMEOUT = 2; static run_on_thread_cb g_callback = NULL; static volatile size_t g_tids_len = 0; -static redisAtomic size_t g_num_threads_done = 0; +static serverAtomic size_t g_num_threads_done = 0; /* This flag is set while ThreadsManager_runOnThreads is running */ -static redisAtomic int g_in_progress = 0; +static serverAtomic int g_in_progress = 0; /*============================ Internal prototypes ========================== */ diff --git a/src/zmalloc.c b/src/zmalloc.c index 27b64dc0d..65ad1f4c6 100644 --- a/src/zmalloc.c +++ b/src/zmalloc.c @@ -90,7 +90,7 @@ void zlibc_free(void *ptr) { #define update_zmalloc_stat_alloc(__n) atomicIncr(used_memory,(__n)) #define update_zmalloc_stat_free(__n) atomicDecr(used_memory,(__n)) -static redisAtomic size_t used_memory = 0; +static serverAtomic size_t used_memory = 0; static void zmalloc_default_oom(size_t size) { fprintf(stderr, "zmalloc: Out of memory trying to allocate %zu bytes\n",