Skip to content

Commit 420ccdf

Browse files
committed
Fix module test failures due to locking
1 parent 41466a4 commit 420ccdf

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/module.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ static int s_cAcquisitionsServer = 0;
329329
static int s_cAcquisitionsModule = 0;
330330
static std::mutex s_mutex;
331331
static std::condition_variable s_cv;
332+
static std::recursive_mutex s_mutexModule;
332333

333334
typedef void (*RedisModuleForkDoneHandler) (int exitcode, int bysignal, void *user_data);
334335

@@ -5055,6 +5056,7 @@ void moduleAcquireGIL(int fServerThread) {
50555056
}
50565057
else
50575058
{
5059+
s_mutexModule.lock();
50585060
++s_cAcquisitionsModule;
50595061
fModuleGILWlocked++;
50605062
}
@@ -5079,6 +5081,8 @@ int moduleTryAcquireGIL(bool fServerThread) {
50795081
}
50805082
else
50815083
{
5084+
if (!s_mutexModule.try_lock())
5085+
return 1;
50825086
++s_cAcquisitionsModule;
50835087
fModuleGILWlocked++;
50845088
}
@@ -5098,6 +5102,7 @@ void moduleReleaseGIL(int fServerThread) {
50985102
}
50995103
else
51005104
{
5105+
s_mutexModule.unlock();
51015106
--s_cAcquisitionsModule;
51025107
fModuleGILWlocked--;
51035108
}

0 commit comments

Comments
 (0)