Skip to content

Commit 9236388

Browse files
committed
Testing failed CI test for MacOS
1 parent 7e47bff commit 9236388

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

src/main/ipc/SharedMutex.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,10 @@ namespace lsp
496496
// Check that we don't lock the mutex again
497497
const thread_id_t tid = Thread::current_thread_id();
498498
if (atomic_load(&nOwner) == tid)
499+
{
500+
lsp_warn("Already locked mutex");
499501
return STATUS_LOCKED;
502+
}
500503

501504
#ifdef PLATFORM_WINDOWS
502505
DWORD res = WaitForSingleObject(hLock, delay);
@@ -536,7 +539,9 @@ namespace lsp
536539
{
537540
case 0: break;
538541
case EDEADLK: return STATUS_BAD_STATE;
539-
case EBUSY: return STATUS_LOCKED;
542+
case EBUSY:
543+
lsp_warn("got EBUSY error");
544+
return STATUS_LOCKED;
540545
case ETIMEDOUT: return STATUS_TIMED_OUT;
541546
case EOWNERDEAD:
542547
{

src/test/utest/ipc/shmutex.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ UTEST_BEGIN("runtime.ipc", shmutex)
4242

4343
data.append_ascii(event);
4444
data.append('=');
45-
data.append_ascii((code == expected) ? "true" : "false");
45+
if (code == expected)
46+
data.append_ascii("true");
47+
else
48+
data.fmt_append_ascii("false(code=%d)", int(code));
4649
data.append(';');
4750
}
4851
} context_t;
@@ -55,9 +58,9 @@ UTEST_BEGIN("runtime.ipc", shmutex)
5558

5659
ipc::Thread::sleep(500);
5760
ctx->log(mutex.open("test-lsp.lock"), "open1", STATUS_OK);
58-
ctx->log(mutex.lock(), "SYNC1", STATUS_OK);
59-
ipc::Thread::sleep(800);
60-
ctx->log(mutex.unlock(), "SYNC2", STATUS_OK);
61+
ctx->log(mutex.lock(), "SYNC1.lock", STATUS_OK);
62+
ipc::Thread::sleep(1600);
63+
ctx->log(mutex.unlock(), "SYNC2.unlock", STATUS_OK);
6164

6265
return STATUS_OK;
6366
}
@@ -72,15 +75,15 @@ UTEST_BEGIN("runtime.ipc", shmutex)
7275

7376
ipc::Thread::sleep(500);
7477

75-
ctx->log(mutex.unlock(), "SYNC1", STATUS_OK);
78+
ctx->log(mutex.unlock(), "SYNC1.unlock", STATUS_OK);
7679

7780
ipc::Thread::sleep(100);
7881

7982
ctx->log(mutex.try_lock(), "trylock2", STATUS_RETRY);
80-
ctx->log(mutex.lock(500), "timedlock2", STATUS_TIMED_OUT);
81-
ctx->log(mutex.lock(500), "SYNC2", STATUS_OK);
83+
ctx->log(mutex.lock(1000), "timedlock2", STATUS_TIMED_OUT);
84+
ctx->log(mutex.lock(1000), "SYNC2.lock", STATUS_OK);
8285
ipc::Thread::sleep(200);
83-
ctx->log(mutex.unlock(), "SYNC3", STATUS_OK);
86+
ctx->log(mutex.unlock(), "SYNC3.unlock", STATUS_OK);
8487

8588
return STATUS_OK;
8689
}
@@ -141,17 +144,17 @@ UTEST_BEGIN("runtime.ipc", shmutex)
141144
ctx.log(STATUS_OK, "unlock", STATUS_OK);
142145
UTEST_ASSERT(mutex.unlock() == STATUS_OK);
143146

144-
ipc::Thread::sleep(2000);
145-
ctx.log(mutex.lock(), "SYNC3", STATUS_OK);
147+
ipc::Thread::sleep(2800);
148+
ctx.log(mutex.lock(), "SYNC3.lock", STATUS_OK);
146149
ctx.log(mutex.unlock(), "unlock", STATUS_OK);
147150

148151
ctx.log(mutex.close(), "close", STATUS_OK);
149152

150153
static const char *expected =
151154
"open=true;lock=true;start=true;sleep=true;open2=true;unlock=true;lock2=true;open1=true;"
152-
"SYNC1=true;SYNC1=true;trylock2=true;timedlock2=true;"
153-
"SYNC2=true;SYNC2=true;"
154-
"SYNC3=true;SYNC3=true;unlock=true;close=true;";
155+
"SYNC1.unlock=true;SYNC1.lock=true;trylock2=true;timedlock2=true;"
156+
"SYNC2.unlock=true;SYNC2.lock=true;"
157+
"SYNC3.unlock=true;SYNC3.lock=true;unlock=true;close=true;";
155158

156159
printf("Result content: %s\n", ctx.data.get_ascii());
157160
printf("Expected content: %s\n", expected);

0 commit comments

Comments
 (0)