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::mutex s_mutex;
|
||||||
static std::condition_variable s_cv;
|
static std::condition_variable s_cv;
|
||||||
static std::recursive_mutex s_mutexModule;
|
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;
|
thread_local bool g_fModuleThread = false;
|
||||||
|
|
||||||
typedef void (*RedisModuleForkDoneHandler) (int exitcode, int bysignal, void *user_data);
|
typedef void (*RedisModuleForkDoneHandler) (int exitcode, int bysignal, void *user_data);
|
||||||
@ -4775,7 +4774,7 @@ int moduleClientIsBlockedOnKeys(client *c) {
|
|||||||
* callback via RM_GetBlockedClientPrivateData). */
|
* callback via RM_GetBlockedClientPrivateData). */
|
||||||
int RM_UnblockClient(RedisModuleBlockedClient *bc, void *privdata) {
|
int RM_UnblockClient(RedisModuleBlockedClient *bc, void *privdata) {
|
||||||
if (serverTL == nullptr) {
|
if (serverTL == nullptr) {
|
||||||
serverTL = &vars;
|
serverTL = &g_pserver->modulethreadvar;
|
||||||
g_fModuleThread = true;
|
g_fModuleThread = true;
|
||||||
}
|
}
|
||||||
if (bc->blocked_on_keys) {
|
if (bc->blocked_on_keys) {
|
||||||
@ -5058,7 +5057,7 @@ void RM_FreeThreadSafeContext(RedisModuleCtx *ctx) {
|
|||||||
void RM_ThreadSafeContextLock(RedisModuleCtx *ctx) {
|
void RM_ThreadSafeContextLock(RedisModuleCtx *ctx) {
|
||||||
UNUSED(ctx);
|
UNUSED(ctx);
|
||||||
if (serverTL == nullptr) {
|
if (serverTL == nullptr) {
|
||||||
serverTL = &vars;
|
serverTL = &g_pserver->modulethreadvar;
|
||||||
g_fModuleThread = true;
|
g_fModuleThread = true;
|
||||||
}
|
}
|
||||||
moduleAcquireGIL(FALSE /*fServerThread*/, true /*fExclusive*/);
|
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->rgthreadvar+iel, iel == IDX_EVENT_LOOP_MAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initServerThread(&g_pserver->modulethreadvar, false);
|
||||||
readOOMScoreAdj();
|
readOOMScoreAdj();
|
||||||
initServer();
|
initServer();
|
||||||
initNetworking(cserver.cthreads > 1 /* fReusePort */);
|
initNetworking(cserver.cthreads > 1 /* fReusePort */);
|
||||||
|
@ -1492,6 +1492,7 @@ struct redisServer {
|
|||||||
::dict *orig_commands; /* Command table before command renaming. */
|
::dict *orig_commands; /* Command table before command renaming. */
|
||||||
|
|
||||||
struct redisServerThreadVars rgthreadvar[MAX_EVENT_LOOPS];
|
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];
|
pthread_t rgthread[MAX_EVENT_LOOPS];
|
||||||
|
|
||||||
std::atomic<unsigned int> lruclock; /* Clock for LRU eviction */
|
std::atomic<unsigned int> lruclock; /* Clock for LRU eviction */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user