Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite6c7509

Browse files
knizhnikkelvich
authored andcommitted
Correctly handle lock failure in MtmLock
1 parent00bdad3 commite6c7509

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

‎multimaster.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,19 +317,22 @@ void MtmLock(LWLockMode mode)
317317
atexit(MtmReleaseLocks);
318318
MtmAtExitHookRegistered= true;
319319
}
320-
if (mode==LW_EXCLUSIVE||MtmLockCount!=0) {
321-
if (MtmLockCount++!=0) {
322-
Assert(Mtm->lastLockHolder==MyProcPid);
323-
return;
324-
}
320+
if (MtmLockCount!=0) {
321+
Assert(Mtm->lastLockHolder==MyProcPid);
322+
MtmLockCount+=1;
323+
return;
325324
}
326325
start=MtmGetSystemTime();
327326
LWLockAcquire((LWLockId)&Mtm->locks[MTM_STATE_LOCK_ID],mode);
328327
stop=MtmGetSystemTime();
329328
if (stop>start+MSEC_TO_USEC(MtmHeartbeatSendTimeout)) {
330329
MTM_LOG1("%d: obtaining %s lock takes %lld microseconds",MyProcPid, (mode==LW_EXCLUSIVE ?"exclusive" :"shared"),stop-start);
331330
}
332-
Mtm->lastLockHolder=MyProcPid;
331+
if (mode==LW_EXCLUSIVE) {
332+
Assert(MtmLockCount==0);
333+
Mtm->lastLockHolder=MyProcPid;
334+
MtmLockCount=1;
335+
}
333336
}
334337

335338
voidMtmUnlock(void)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp