Rename redisAtomic to serverAtomic (#180)

https://github.com/valkey-io/valkey/issues/144

Signed-off-by: 0del <bany.y0599@gmail.com>
This commit is contained in:
0del 2024-04-04 01:29:33 +07:00 committed by GitHub
parent f753db5141
commit 8b3ab8f74f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 30 additions and 30 deletions

View File

@ -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 <stdatomic.h>

View File

@ -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. */

View File

@ -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];

View File

@ -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;

View File

@ -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. */

View File

@ -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 ========================== */

View File

@ -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",