mirror of
http://github.com/valkey-io/valkey
synced 2024-11-22 00:52:38 +00:00
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:
parent
f753db5141
commit
8b3ab8f74f
@ -80,8 +80,8 @@
|
|||||||
#ifndef __ATOMIC_VAR_H
|
#ifndef __ATOMIC_VAR_H
|
||||||
#define __ATOMIC_VAR_H
|
#define __ATOMIC_VAR_H
|
||||||
|
|
||||||
/* Define redisAtomic for atomic variable. */
|
/* Define serverAtomic for atomic variable. */
|
||||||
#define redisAtomic
|
#define serverAtomic
|
||||||
|
|
||||||
/* To test Redis with Helgrind (a Valgrind tool) it is useful to define
|
/* 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
|
* 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__) && \
|
#if !defined(__ATOMIC_VAR_FORCE_SYNC_MACROS) && defined(__STDC_VERSION__) && \
|
||||||
(__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__)
|
(__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__)
|
||||||
/* Use '_Atomic' keyword if the compiler supports. */
|
/* Use '_Atomic' keyword if the compiler supports. */
|
||||||
#undef redisAtomic
|
#undef serverAtomic
|
||||||
#define redisAtomic _Atomic
|
#define serverAtomic _Atomic
|
||||||
/* Implementation using _Atomic in C11. */
|
/* Implementation using _Atomic in C11. */
|
||||||
|
|
||||||
#include <stdatomic.h>
|
#include <stdatomic.h>
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "cluster.h"
|
#include "cluster.h"
|
||||||
|
|
||||||
static redisAtomic size_t lazyfree_objects = 0;
|
static serverAtomic size_t lazyfree_objects = 0;
|
||||||
static redisAtomic size_t lazyfreed_objects = 0;
|
static serverAtomic size_t lazyfreed_objects = 0;
|
||||||
|
|
||||||
/* Release objects from the lazyfree thread. It's just decrRefCount()
|
/* Release objects from the lazyfree thread. It's just decrRefCount()
|
||||||
* updating the count of objects to release. */
|
* updating the count of objects to release. */
|
||||||
|
@ -4195,7 +4195,7 @@ void processEventsWhileBlocked(void) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct __attribute__((aligned(CACHE_LINE_SIZE))) threads_pending {
|
typedef struct __attribute__((aligned(CACHE_LINE_SIZE))) threads_pending {
|
||||||
redisAtomic unsigned long value;
|
serverAtomic unsigned long value;
|
||||||
} threads_pending;
|
} threads_pending;
|
||||||
|
|
||||||
pthread_t io_threads[IO_THREADS_MAX_NUM];
|
pthread_t io_threads[IO_THREADS_MAX_NUM];
|
||||||
|
@ -85,11 +85,11 @@ static struct config {
|
|||||||
int tls;
|
int tls;
|
||||||
struct cliSSLconfig sslconfig;
|
struct cliSSLconfig sslconfig;
|
||||||
int numclients;
|
int numclients;
|
||||||
redisAtomic int liveclients;
|
serverAtomic int liveclients;
|
||||||
int requests;
|
int requests;
|
||||||
redisAtomic int requests_issued;
|
serverAtomic int requests_issued;
|
||||||
redisAtomic int requests_finished;
|
serverAtomic int requests_finished;
|
||||||
redisAtomic int previous_requests_finished;
|
serverAtomic int previous_requests_finished;
|
||||||
int last_printed_bytes;
|
int last_printed_bytes;
|
||||||
long long previous_tick;
|
long long previous_tick;
|
||||||
int keysize;
|
int keysize;
|
||||||
@ -118,9 +118,9 @@ static struct config {
|
|||||||
struct redisConfig *redis_config;
|
struct redisConfig *redis_config;
|
||||||
struct hdr_histogram* latency_histogram;
|
struct hdr_histogram* latency_histogram;
|
||||||
struct hdr_histogram* current_sec_latency_histogram;
|
struct hdr_histogram* current_sec_latency_histogram;
|
||||||
redisAtomic int is_fetching_slots;
|
serverAtomic int is_fetching_slots;
|
||||||
redisAtomic int is_updating_slots;
|
serverAtomic int is_updating_slots;
|
||||||
redisAtomic int slots_last_update;
|
serverAtomic int slots_last_update;
|
||||||
int enable_tracking;
|
int enable_tracking;
|
||||||
pthread_mutex_t liveclients_mutex;
|
pthread_mutex_t liveclients_mutex;
|
||||||
pthread_mutex_t is_updating_slots_mutex;
|
pthread_mutex_t is_updating_slots_mutex;
|
||||||
|
26
src/server.h
26
src/server.h
@ -1594,7 +1594,7 @@ struct redisServer {
|
|||||||
int module_pipe[2]; /* Pipe used to awake the event loop by module threads. */
|
int module_pipe[2]; /* Pipe used to awake the event loop by module threads. */
|
||||||
pid_t child_pid; /* PID of current child */
|
pid_t child_pid; /* PID of current child */
|
||||||
int child_type; /* Type 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 */
|
/* Networking */
|
||||||
int port; /* TCP listening port */
|
int port; /* TCP listening port */
|
||||||
int tls_port; /* TLS listening port */
|
int tls_port; /* TLS listening port */
|
||||||
@ -1633,7 +1633,7 @@ struct redisServer {
|
|||||||
pause_event client_pause_per_purpose[NUM_PAUSE_PURPOSES];
|
pause_event client_pause_per_purpose[NUM_PAUSE_PURPOSES];
|
||||||
char neterr[ANET_ERR_LEN]; /* Error buffer for anet.c */
|
char neterr[ANET_ERR_LEN]; /* Error buffer for anet.c */
|
||||||
dict *migrate_cached_sockets;/* MIGRATE cached sockets */
|
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 protected_mode; /* Don't accept external connections. */
|
||||||
int io_threads_num; /* Number of IO threads to use. */
|
int io_threads_num; /* Number of IO threads to use. */
|
||||||
int io_threads_do_reads; /* Read and parse from IO threads? */
|
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) */
|
long long slowlog_log_slower_than; /* SLOWLOG time limit (to get logged) */
|
||||||
unsigned long slowlog_max_len; /* SLOWLOG max number of items logged */
|
unsigned long slowlog_max_len; /* SLOWLOG max number of items logged */
|
||||||
struct malloc_stats cron_malloc_stats; /* sampled in serverCron(). */
|
struct malloc_stats cron_malloc_stats; /* sampled in serverCron(). */
|
||||||
redisAtomic long long stat_net_input_bytes; /* Bytes read from network. */
|
serverAtomic long long stat_net_input_bytes; /* Bytes read from network. */
|
||||||
redisAtomic long long stat_net_output_bytes; /* Bytes written to network. */
|
serverAtomic 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'. */
|
serverAtomic 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_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_peak; /* Peak size of copy on write bytes. */
|
||||||
size_t stat_current_cow_bytes; /* Copy on write bytes while child is active. */
|
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 */
|
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_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_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 */
|
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 */
|
serverAtomic 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 */
|
serverAtomic 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_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 */
|
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
|
/* The following two are used to track instantaneous metrics, like
|
||||||
* number of operations per second, network traffic. */
|
* 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_last_write_errno; /* Valid if aof write/fsync status is ERR */
|
||||||
int aof_load_truncated; /* Don't stop on unexpected AOF EOF. */
|
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. */
|
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. */
|
serverAtomic 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_errno; /* Errno of AOF fsync in bio job. */
|
||||||
aofManifest *aof_manifest; /* Used to track AOFs. */
|
aofManifest *aof_manifest; /* Used to track AOFs. */
|
||||||
int aof_disable_auto_gc; /* If disable automatically deleting HISTORY type AOFs?
|
int aof_disable_auto_gc; /* If disable automatically deleting HISTORY type AOFs?
|
||||||
default no. (for testings). */
|
default no. (for testings). */
|
||||||
@ -1866,7 +1866,7 @@ struct redisServer {
|
|||||||
char replid2[CONFIG_RUN_ID_SIZE+1]; /* replid inherited from master*/
|
char replid2[CONFIG_RUN_ID_SIZE+1]; /* replid inherited from master*/
|
||||||
long long master_repl_offset; /* My current replication offset */
|
long long master_repl_offset; /* My current replication offset */
|
||||||
long long second_replid_offset; /* Accept offsets up to this for replid2. */
|
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
|
* potentially have been fsynced, applied to
|
||||||
fsynced_reploff only when AOF state is AOF_ON
|
fsynced_reploff only when AOF state is AOF_ON
|
||||||
(not during the initial rewrite) */
|
(not during the initial rewrite) */
|
||||||
@ -1974,7 +1974,7 @@ struct redisServer {
|
|||||||
int list_max_listpack_size;
|
int list_max_listpack_size;
|
||||||
int list_compress_depth;
|
int list_compress_depth;
|
||||||
/* time cache */
|
/* 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(). */
|
time_t timezone; /* Cached timezone. As set by tzset(). */
|
||||||
int daylight_active; /* Currently in daylight saving time. */
|
int daylight_active; /* Currently in daylight saving time. */
|
||||||
mstime_t mstime; /* 'unixtime' in milliseconds. */
|
mstime_t mstime; /* 'unixtime' in milliseconds. */
|
||||||
|
@ -46,10 +46,10 @@ static const clock_t RUN_ON_THREADS_TIMEOUT = 2;
|
|||||||
|
|
||||||
static run_on_thread_cb g_callback = NULL;
|
static run_on_thread_cb g_callback = NULL;
|
||||||
static volatile size_t g_tids_len = 0;
|
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 */
|
/* 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 ========================== */
|
/*============================ Internal prototypes ========================== */
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ void zlibc_free(void *ptr) {
|
|||||||
#define update_zmalloc_stat_alloc(__n) atomicIncr(used_memory,(__n))
|
#define update_zmalloc_stat_alloc(__n) atomicIncr(used_memory,(__n))
|
||||||
#define update_zmalloc_stat_free(__n) atomicDecr(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) {
|
static void zmalloc_default_oom(size_t size) {
|
||||||
fprintf(stderr, "zmalloc: Out of memory trying to allocate %zu bytes\n",
|
fprintf(stderr, "zmalloc: Out of memory trying to allocate %zu bytes\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user