diff --git a/src/aof.c b/src/aof.c index cb9c43136..c775d5b61 100644 --- a/src/aof.c +++ b/src/aof.c @@ -2467,12 +2467,12 @@ int rewriteAppendOnlyFileBackground(void) { server.stat_aof_rewrites++; - if ((childpid = redisFork(CHILD_TYPE_AOF)) == 0) { + if ((childpid = serverFork(CHILD_TYPE_AOF)) == 0) { char tmpfile[256]; /* Child */ - redisSetProcTitle("redis-aof-rewrite"); - redisSetCpuAffinity(server.aof_rewrite_cpulist); + serverSetProcTitle("redis-aof-rewrite"); + serverSetCpuAffinity(server.aof_rewrite_cpulist); snprintf(tmpfile,256,"temp-rewriteaof-bg-%d.aof", (int) getpid()); if (rewriteAppendOnlyFile(tmpfile) == C_OK) { serverLog(LL_NOTICE, diff --git a/src/bio.c b/src/bio.c index 10ecf8db2..da6222242 100644 --- a/src/bio.c +++ b/src/bio.c @@ -212,7 +212,7 @@ void *bioProcessBackgroundJobs(void *arg) { redis_set_thread_title(bio_worker_title[worker]); - redisSetCpuAffinity(server.bio_cpulist); + serverSetCpuAffinity(server.bio_cpulist); makeThreadKillable(); diff --git a/src/bitops.c b/src/bitops.c index 925c2a71d..bc76d9acb 100644 --- a/src/bitops.c +++ b/src/bitops.c @@ -37,7 +37,7 @@ /* Count number of bits set in the binary array pointed by 's' and long * 'count' bytes. The implementation of this function is required to * work with an input string length up to 512 MB or more (server.proto_max_bulk_len) */ -long long redisPopcount(void *s, long count) { +long long serverPopcount(void *s, long count) { long long bits = 0; unsigned char *p = s; uint32_t *p4; @@ -870,7 +870,7 @@ void bitcountCommand(client *c) { addReply(c,shared.czero); } else { long bytes = (long)(end-start+1); - long long count = redisPopcount(p+start,bytes); + long long count = serverPopcount(p+start,bytes); if (first_byte_neg_mask != 0 || last_byte_neg_mask != 0) { unsigned char firstlast[2] = {0, 0}; /* We may count bits of first byte and last byte which are out of @@ -878,7 +878,7 @@ void bitcountCommand(client *c) { * bits in the range to zero. So these bit will not be excluded. */ if (first_byte_neg_mask != 0) firstlast[0] = p[start] & first_byte_neg_mask; if (last_byte_neg_mask != 0) firstlast[1] = p[end] & last_byte_neg_mask; - count -= redisPopcount(firstlast,2); + count -= serverPopcount(firstlast,2); } addReplyLongLong(c,count); } diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index 4e4f9425d..edb510d6e 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -805,7 +805,7 @@ int clusterLockConfig(char *filename) { * we'll retain the lock to the file as long as the process exists. * * After fork, the child process will get the fd opened by the parent process, - * we need save `fd` to `cluster_config_file_lock_fd`, so that in redisFork(), + * we need save `fd` to `cluster_config_file_lock_fd`, so that in serverFork(), * it will be closed in the child process. * If it is not closed, when the main process is killed -9, but the child process * (redis-aof-rewrite) is still alive, the fd(lock) will still be held by the diff --git a/src/config.c b/src/config.c index 888567a15..8b193891c 100644 --- a/src/config.c +++ b/src/config.c @@ -2445,7 +2445,7 @@ static int updateLocaleCollate(const char **err) { } static int updateProcTitleTemplate(const char **err) { - if (redisSetProcTitle(NULL) == C_ERR) { + if (serverSetProcTitle(NULL) == C_ERR) { *err = "failed to set process title"; return 0; } diff --git a/src/eval.c b/src/eval.c index a0e6a6573..2561322f3 100644 --- a/src/eval.c +++ b/src/eval.c @@ -865,7 +865,7 @@ void ldbSendLogs(void) { int ldbStartSession(client *c) { ldb.forked = (c->flags & CLIENT_LUA_DEBUG_SYNC) == 0; if (ldb.forked) { - pid_t cp = redisFork(CHILD_TYPE_LDB); + pid_t cp = serverFork(CHILD_TYPE_LDB); if (cp == -1) { addReplyErrorFormat(c,"Fork() failed: can't run EVAL in debugging mode: %s", strerror(errno)); return 0; diff --git a/src/module.c b/src/module.c index af0d92cf8..231484546 100644 --- a/src/module.c +++ b/src/module.c @@ -11248,9 +11248,9 @@ int RM_ScanKey(RedisModuleKey *key, RedisModuleScanCursor *cursor, RedisModuleSc int RM_Fork(RedisModuleForkDoneHandler cb, void *user_data) { pid_t childpid; - if ((childpid = redisFork(CHILD_TYPE_MODULE)) == 0) { + if ((childpid = serverFork(CHILD_TYPE_MODULE)) == 0) { /* Child */ - redisSetProcTitle("redis-module-fork"); + serverSetProcTitle("redis-module-fork"); } else if (childpid == -1) { serverLog(LL_WARNING,"Can't fork for module: %s", strerror(errno)); } else { diff --git a/src/networking.c b/src/networking.c index 90825ca28..e979e2ecc 100644 --- a/src/networking.c +++ b/src/networking.c @@ -4226,7 +4226,7 @@ void *IOThreadMain(void *myid) { snprintf(thdname, sizeof(thdname), "io_thd_%ld", id); redis_set_thread_title(thdname); - redisSetCpuAffinity(server.server_cpulist); + serverSetCpuAffinity(server.server_cpulist); makeThreadKillable(); while(1) { diff --git a/src/rdb.c b/src/rdb.c index 688437ddd..103934049 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -1577,12 +1577,12 @@ int rdbSaveBackground(int req, char *filename, rdbSaveInfo *rsi, int rdbflags) { server.dirty_before_bgsave = server.dirty; server.lastbgsave_try = time(NULL); - if ((childpid = redisFork(CHILD_TYPE_RDB)) == 0) { + if ((childpid = serverFork(CHILD_TYPE_RDB)) == 0) { int retval; /* Child */ - redisSetProcTitle("redis-rdb-bgsave"); - redisSetCpuAffinity(server.bgsave_cpulist); + serverSetProcTitle("redis-rdb-bgsave"); + serverSetCpuAffinity(server.bgsave_cpulist); retval = rdbSave(req, filename,rsi,rdbflags); if (retval == C_OK) { sendChildCowInfo(CHILD_INFO_TYPE_RDB_COW_SIZE, "RDB"); @@ -3583,7 +3583,7 @@ int rdbSaveToSlavesSockets(int req, rdbSaveInfo *rsi) { } /* Create the child process. */ - if ((childpid = redisFork(CHILD_TYPE_RDB)) == 0) { + if ((childpid = serverFork(CHILD_TYPE_RDB)) == 0) { /* Child */ int retval, dummy; rio rdb; @@ -3594,8 +3594,8 @@ int rdbSaveToSlavesSockets(int req, rdbSaveInfo *rsi) { * get a write error and exit. */ close(server.rdb_pipe_read); - redisSetProcTitle("redis-rdb-to-slaves"); - redisSetCpuAffinity(server.bgsave_cpulist); + serverSetProcTitle("redis-rdb-to-slaves"); + serverSetCpuAffinity(server.bgsave_cpulist); retval = rdbSaveRioWithEOFMark(req,&rdb,NULL,rsi); if (retval == C_OK && rioFlush(&rdb) == 0) diff --git a/src/replication.c b/src/replication.c index d2ea5bbf2..eec67e06b 100644 --- a/src/replication.c +++ b/src/replication.c @@ -2288,7 +2288,7 @@ void readSyncBulkPayload(connection *conn) { serverLog(LL_NOTICE, "MASTER <-> REPLICA sync: Finished with success"); if (server.supervised_mode == SUPERVISED_SYSTEMD) { - redisCommunicateSystemd("STATUS=MASTER <-> REPLICA sync: Finished with success. Ready to accept connections in read-write mode.\n"); + serverCommunicateSystemd("STATUS=MASTER <-> REPLICA sync: Finished with success. Ready to accept connections in read-write mode.\n"); } /* Send the initial ACK immediately to put this replica in online state. */ @@ -2859,7 +2859,7 @@ void syncWithMaster(connection *conn) { if (psync_result == PSYNC_CONTINUE) { serverLog(LL_NOTICE, "MASTER <-> REPLICA sync: Master accepted a Partial Resynchronization."); if (server.supervised_mode == SUPERVISED_SYSTEMD) { - redisCommunicateSystemd("STATUS=MASTER <-> REPLICA sync: Partial Resynchronization accepted. Ready to accept connections in read-write mode.\n"); + serverCommunicateSystemd("STATUS=MASTER <-> REPLICA sync: Partial Resynchronization accepted. Ready to accept connections in read-write mode.\n"); } return; } diff --git a/src/server.c b/src/server.c index eab88ce7b..43727a24e 100644 --- a/src/server.c +++ b/src/server.c @@ -4318,7 +4318,7 @@ int prepareForShutdown(int flags) { serverLog(LL_NOTICE,"User requested shutdown..."); if (server.supervised_mode == SUPERVISED_SYSTEMD) - redisCommunicateSystemd("STOPPING=1\n"); + serverCommunicateSystemd("STOPPING=1\n"); /* If we have any replicas, let them catch up the replication offset before * we shut down, to avoid data loss. */ @@ -4454,7 +4454,7 @@ int finishShutdown(void) { } else { serverLog(LL_WARNING, "Writing initial AOF, can't exit."); if (server.supervised_mode == SUPERVISED_SYSTEMD) - redisCommunicateSystemd("STATUS=Writing initial AOF, can't exit.\n"); + serverCommunicateSystemd("STATUS=Writing initial AOF, can't exit.\n"); goto error; } } @@ -4476,7 +4476,7 @@ int finishShutdown(void) { if ((server.saveparamslen > 0 && !nosave) || save) { serverLog(LL_NOTICE,"Saving the final RDB snapshot before exiting."); if (server.supervised_mode == SUPERVISED_SYSTEMD) - redisCommunicateSystemd("STATUS=Saving the final RDB snapshot\n"); + serverCommunicateSystemd("STATUS=Saving the final RDB snapshot\n"); /* Snapshotting. Perform a SYNC SAVE and exit */ rdbSaveInfo rsi, *rsiptr; rsiptr = rdbPopulateSaveInfo(&rsi); @@ -4492,7 +4492,7 @@ int finishShutdown(void) { } else { serverLog(LL_WARNING,"Error trying to save the DB, can't exit."); if (server.supervised_mode == SUPERVISED_SYSTEMD) - redisCommunicateSystemd("STATUS=Error trying to save the DB, can't exit.\n"); + serverCommunicateSystemd("STATUS=Error trying to save the DB, can't exit.\n"); goto error; } } @@ -6349,7 +6349,7 @@ int changeListener(connListener *listener) { /* Just close the server if port disabled */ if (listener->port == 0) { - if (server.set_proc_title) redisSetProcTitle(NULL); + if (server.set_proc_title) serverSetProcTitle(NULL); return C_OK; } @@ -6363,7 +6363,7 @@ int changeListener(connListener *listener) { serverPanic("Unrecoverable error creating %s accept handler.", listener->ct->get_type(NULL)); } - if (server.set_proc_title) redisSetProcTitle(NULL); + if (server.set_proc_title) serverSetProcTitle(NULL); return C_OK; } @@ -6449,7 +6449,7 @@ void closeChildUnusedResourceAfterFork(void) { } /* purpose is one of CHILD_TYPE_ types */ -int redisFork(int purpose) { +int serverFork(int purpose) { if (isMutuallyExclusiveChildType(purpose)) { if (hasActiveChildProcess()) { errno = EEXIST; @@ -6749,7 +6749,7 @@ int validateProcTitleTemplate(const char *template) { return ok; } -int redisSetProcTitle(char *title) { +int serverSetProcTitle(char *title) { #ifdef USE_SETPROCTITLE if (!title) title = server.exec_argv[0]; sds proc_title = expandProcTitleTemplate(server.proc_title_template, title); @@ -6764,7 +6764,7 @@ int redisSetProcTitle(char *title) { return C_OK; } -void redisSetCpuAffinity(const char *cpulist) { +void serverSetCpuAffinity(const char *cpulist) { #ifdef USE_SETCPUAFFINITY setcpuaffinity(cpulist); #else @@ -6774,7 +6774,7 @@ void redisSetCpuAffinity(const char *cpulist) { /* Send a notify message to systemd. Returns sd_notify return code which is * a positive number on success. */ -int redisCommunicateSystemd(const char *sd_notify_msg) { +int serverCommunicateSystemd(const char *sd_notify_msg) { #ifdef HAVE_LIBSYSTEMD int ret = sd_notify(0, sd_notify_msg); @@ -6812,7 +6812,7 @@ static int redisSupervisedSystemd(void) { "systemd supervision requested or auto-detected, but Redis is compiled without libsystemd support!"); return 0; #else - if (redisCommunicateSystemd("STATUS=Redis is loading...\n") <= 0) + if (serverCommunicateSystemd("STATUS=Redis is loading...\n") <= 0) return 0; serverLog(LL_NOTICE, "Supervised by systemd. Please make sure you set appropriate values for TimeoutStartSec and TimeoutStopSec in your service unit."); @@ -7169,7 +7169,7 @@ int main(int argc, char **argv) { initServer(); if (background || server.pidfile) createPidFile(); - if (server.set_proc_title) redisSetProcTitle(NULL); + if (server.set_proc_title) serverSetProcTitle(NULL); redisAsciiArt(); checkTcpBacklogSettings(); if (server.cluster_enabled) { @@ -7207,17 +7207,17 @@ int main(int argc, char **argv) { if (server.supervised_mode == SUPERVISED_SYSTEMD) { if (!server.masterhost) { - redisCommunicateSystemd("STATUS=Ready to accept connections\n"); + serverCommunicateSystemd("STATUS=Ready to accept connections\n"); } else { - redisCommunicateSystemd("STATUS=Ready to accept connections in read-only mode. Waiting for MASTER <-> REPLICA sync\n"); + serverCommunicateSystemd("STATUS=Ready to accept connections in read-only mode. Waiting for MASTER <-> REPLICA sync\n"); } - redisCommunicateSystemd("READY=1\n"); + serverCommunicateSystemd("READY=1\n"); } } else { sentinelIsRunning(); if (server.supervised_mode == SUPERVISED_SYSTEMD) { - redisCommunicateSystemd("STATUS=Ready to accept connections\n"); - redisCommunicateSystemd("READY=1\n"); + serverCommunicateSystemd("STATUS=Ready to accept connections\n"); + serverCommunicateSystemd("READY=1\n"); } } @@ -7226,7 +7226,7 @@ int main(int argc, char **argv) { serverLog(LL_WARNING,"WARNING: You specified a maxmemory value that is less than 1MB (current value is %llu bytes). Are you sure this is what you really want?", server.maxmemory); } - redisSetCpuAffinity(server.server_cpulist); + serverSetCpuAffinity(server.server_cpulist); setOOMScoreAdj(-1); aeMain(server.el); diff --git a/src/server.h b/src/server.h index 3b05c7ca3..07dd1485d 100644 --- a/src/server.h +++ b/src/server.h @@ -2551,11 +2551,11 @@ void getRandomHexChars(char *p, size_t len); void getRandomBytes(unsigned char *p, size_t len); uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l); void exitFromChild(int retcode); -long long redisPopcount(void *s, long count); -int redisSetProcTitle(char *title); +long long serverPopcount(void *s, long count); +int serverSetProcTitle(char *title); int validateProcTitleTemplate(const char *template); -int redisCommunicateSystemd(const char *sd_notify_msg); -void redisSetCpuAffinity(const char *cpulist); +int serverCommunicateSystemd(const char *sd_notify_msg); +void serverSetCpuAffinity(const char *cpulist); /* afterErrorReply flags */ #define ERR_REPLY_FLAG_NO_STATS_UPDATE (1ULL<<0) /* Indicating that we should not update @@ -2906,7 +2906,7 @@ void sendChildInfo(childInfoType info_type, size_t keys, char *pname); void receiveChildInfo(void); /* Fork helpers */ -int redisFork(int purpose); +int serverFork(int purpose); int hasActiveChildProcess(void); void resetChildState(void); int isMutuallyExclusiveChildType(int type);