Created and initialized seperate thread variables for modules
Former-commit-id: 3bb6b16c4a8f692b46040b72a51bef57fa03f1e6
This commit is contained in:
parent
3f9f4f6bff
commit
cb43eda420
@ -329,7 +329,6 @@ static int s_cAcquisitionsModule = 0;
|
||||
static std::mutex s_mutex;
|
||||
static std::condition_variable s_cv;
|
||||
static std::recursive_mutex s_mutexModule;
|
||||
static redisServerThreadVars vars; /* Server thread local variables to be used by module threads */
|
||||
thread_local bool g_fModuleThread = false;
|
||||
|
||||
typedef void (*RedisModuleForkDoneHandler) (int exitcode, int bysignal, void *user_data);
|
||||
@ -4775,7 +4774,7 @@ int moduleClientIsBlockedOnKeys(client *c) {
|
||||
* callback via RM_GetBlockedClientPrivateData). */
|
||||
int RM_UnblockClient(RedisModuleBlockedClient *bc, void *privdata) {
|
||||
if (serverTL == nullptr) {
|
||||
serverTL = &vars;
|
||||
serverTL = &g_pserver->modulethreadvar;
|
||||
g_fModuleThread = true;
|
||||
}
|
||||
if (bc->blocked_on_keys) {
|
||||
@ -5058,7 +5057,7 @@ void RM_FreeThreadSafeContext(RedisModuleCtx *ctx) {
|
||||
void RM_ThreadSafeContextLock(RedisModuleCtx *ctx) {
|
||||
UNUSED(ctx);
|
||||
if (serverTL == nullptr) {
|
||||
serverTL = &vars;
|
||||
serverTL = &g_pserver->modulethreadvar;
|
||||
g_fModuleThread = true;
|
||||
}
|
||||
moduleAcquireGIL(FALSE /*fServerThread*/, true /*fExclusive*/);
|
||||
|
@ -5938,6 +5938,8 @@ int main(int argc, char **argv) {
|
||||
{
|
||||
initServerThread(g_pserver->rgthreadvar+iel, iel == IDX_EVENT_LOOP_MAIN);
|
||||
}
|
||||
|
||||
initServerThread(&g_pserver->modulethreadvar, false);
|
||||
readOOMScoreAdj();
|
||||
initServer();
|
||||
initNetworking(cserver.cthreads > 1 /* fReusePort */);
|
||||
|
@ -1492,6 +1492,7 @@ struct redisServer {
|
||||
::dict *orig_commands; /* Command table before command renaming. */
|
||||
|
||||
struct redisServerThreadVars rgthreadvar[MAX_EVENT_LOOPS];
|
||||
struct redisServerThreadVars modulethreadvar; /* Server thread local variables to be used by module threads */
|
||||
pthread_t rgthread[MAX_EVENT_LOOPS];
|
||||
|
||||
std::atomic<unsigned int> lruclock; /* Clock for LRU eviction */
|
||||
|
Loading…
x
Reference in New Issue
Block a user