| 3869 | } |
| 3870 | |
| 3871 | static void initServerThread(struct redisServerThreadVars *pvar, int fMain) |
| 3872 | { |
| 3873 | pvar->unblocked_clients = listCreate(); |
| 3874 | pvar->clients_pending_asyncwrite = listCreate(); |
| 3875 | pvar->ipfd.count = 0; |
| 3876 | pvar->tlsfd.count = 0; |
| 3877 | pvar->cclients = 0; |
| 3878 | pvar->in_eval = 0; |
| 3879 | pvar->in_exec = 0; |
| 3880 | pvar->el = aeCreateEventLoop(g_pserver->maxclients+CONFIG_FDSET_INCR); |
| 3881 | pvar->current_client = nullptr; |
| 3882 | pvar->fRetrySetAofEvent = false; |
| 3883 | if (pvar->el == NULL) { |
| 3884 | serverLog(LL_WARNING, |
| 3885 | "Failed creating the event loop. Error message: '%s'", |
| 3886 | strerror(errno)); |
| 3887 | exit(1); |
| 3888 | } |
| 3889 | aeSetBeforeSleepProc(pvar->el, beforeSleep, AE_SLEEP_THREADSAFE); |
| 3890 | aeSetAfterSleepProc(pvar->el, afterSleep, AE_SLEEP_THREADSAFE); |
| 3891 | |
| 3892 | fastlock_init(&pvar->lockPendingWrite, "lockPendingWrite"); |
| 3893 | |
| 3894 | if (!fMain) |
| 3895 | { |
| 3896 | if (aeCreateTimeEvent(pvar->el, 1, serverCronLite, NULL, NULL) == AE_ERR) { |
| 3897 | serverPanic("Can't create event loop timers."); |
| 3898 | exit(1); |
| 3899 | } |
| 3900 | } |
| 3901 | |
| 3902 | /* Register a readable event for the pipe used to awake the event loop |
| 3903 | * when a blocked client in a module needs attention. */ |
| 3904 | if (aeCreateFileEvent(pvar->el, g_pserver->module_blocked_pipe[0], AE_READABLE, |
| 3905 | moduleBlockedClientPipeReadable,NULL) == AE_ERR) { |
| 3906 | serverPanic( |
| 3907 | "Error registering the readable event for the module " |
| 3908 | "blocked clients subsystem."); |
| 3909 | } |
| 3910 | } |
| 3911 | |
| 3912 | void initServer(void) { |
| 3913 | signal(SIGHUP, SIG_IGN); |
no test coverage detected