MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / moduleInitModulesSystem

Function moduleInitModulesSystem

src/module.cpp:8640–8681  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8638}
8639
8640void moduleInitModulesSystem(void) {
8641 moduleUnblockedClients = listCreate();
8642 g_pserver->loadmodule_queue = listCreate();
8643 modules = dictCreate(&modulesDictType,NULL);
8644
8645 /* Set up the keyspace notification subscriber list and static client */
8646 moduleKeyspaceSubscribers = listCreate();
8647
8648 /* Set up filter list */
8649 moduleCommandFilters = listCreate();
8650
8651 /* Reusable client for RM_Call() is created on first use */
8652 g_pserver->module_client = NULL;
8653
8654 moduleRegisterCoreAPI();
8655 if (pipe(g_pserver->module_blocked_pipe) == -1) {
8656 serverLog(LL_WARNING,
8657 "Can't create the pipe for module blocking commands: %s",
8658 strerror(errno));
8659 exit(1);
8660 }
8661
8662 /* Make the pipe non blocking. This is just a best effort aware mechanism
8663 * and we do not want to block not in the read nor in the write half. */
8664 anetNonBlock(NULL,g_pserver->module_blocked_pipe[0]);
8665 anetNonBlock(NULL,g_pserver->module_blocked_pipe[1]);
8666
8667 /* Enable close-on-exec flag on pipes in case of the fork-exec system calls in
8668 * sentinels or redis servers. */
8669 anetCloexec(g_pserver->module_blocked_pipe[0]);
8670 anetCloexec(g_pserver->module_blocked_pipe[1]);
8671
8672 /* Create the timers radix tree. */
8673 Timers = raxNew();
8674
8675 /* Setup the event listeners data structures. */
8676 RedisModule_EventListeners = listCreate();
8677
8678 /* Our thread-safe contexts GIL must start with already locked:
8679 * it is just unlocked when it's safe. */
8680 moduleAcquireGIL(true);
8681}
8682
8683/* Load all the modules in the g_pserver->loadmodule_queue list, which is
8684 * populated by `loadmodule` directives in the configuration file.

Callers 1

mainFunction · 0.85

Calls 8

listCreateFunction · 0.85
moduleRegisterCoreAPIFunction · 0.85
serverLogFunction · 0.85
anetNonBlockFunction · 0.85
anetCloexecFunction · 0.85
raxNewFunction · 0.85
moduleAcquireGILFunction · 0.85
dictCreateFunction · 0.70

Tested by

no test coverage detected