| 8439 | } |
| 8440 | |
| 8441 | void moduleInitModulesSystem(void) { |
| 8442 | moduleUnblockedClients = listCreate(); |
| 8443 | server.loadmodule_queue = listCreate(); |
| 8444 | modules = dictCreate(&modulesDictType,NULL); |
| 8445 | |
| 8446 | /* Set up the keyspace notification subscriber list and static client */ |
| 8447 | moduleKeyspaceSubscribers = listCreate(); |
| 8448 | |
| 8449 | /* Set up filter list */ |
| 8450 | moduleCommandFilters = listCreate(); |
| 8451 | |
| 8452 | /* Reusable client for RM_Call() is created on first use */ |
| 8453 | server.module_client = NULL; |
| 8454 | |
| 8455 | moduleRegisterCoreAPI(); |
| 8456 | if (pipe(server.module_blocked_pipe) == -1) { |
| 8457 | serverLog(LL_WARNING, |
| 8458 | "Can't create the pipe for module blocking commands: %s", |
| 8459 | strerror(errno)); |
| 8460 | exit(1); |
| 8461 | } |
| 8462 | /* Make the pipe non blocking. This is just a best effort aware mechanism |
| 8463 | * and we do not want to block not in the read nor in the write half. */ |
| 8464 | anetNonBlock(NULL,server.module_blocked_pipe[0]); |
| 8465 | anetNonBlock(NULL,server.module_blocked_pipe[1]); |
| 8466 | |
| 8467 | /* Enable close-on-exec flag on pipes in case of the fork-exec system calls in |
| 8468 | * sentinels or redis servers. */ |
| 8469 | anetCloexec(server.module_blocked_pipe[0]); |
| 8470 | anetCloexec(server.module_blocked_pipe[1]); |
| 8471 | |
| 8472 | /* Create the timers radix tree. */ |
| 8473 | Timers = raxNew(); |
| 8474 | |
| 8475 | /* Setup the event listeners data structures. */ |
| 8476 | RedisModule_EventListeners = listCreate(); |
| 8477 | |
| 8478 | /* Our thread-safe contexts GIL must start with already locked: |
| 8479 | * it is just unlocked when it's safe. */ |
| 8480 | pthread_mutex_lock(&moduleGIL); |
| 8481 | } |
| 8482 | |
| 8483 | /* Load all the modules in the server.loadmodule_queue list, which is |
| 8484 | * populated by `loadmodule` directives in the configuration file. |
no test coverage detected