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

Commitc9c37e3

Browse files
committed
Fix coding rules violations in walreceiver.c
1. Since commitb1a9bad we had pstrdup() inside aspinlock-protected critical section; reported by Andreas Seltenreich.Turn those into strlcpy() to stack-allocated variables instead.Backpatch to 9.6.2. Since commit9ed551e we had a pfree() uselessly inside aspinlock-protected critical section. Tom Lane noticed in code review.Move down. Backpatch to 9.6.3. Since commit6423390 we had GetCurrentTimestamp() (a kernelcall) inside a spinlock-protected critical section. Tom Lane noticed incode review. Move it up. Backpatch to 9.2.4. Since commit1bb2558 we did elog(PANIC) while holding spinlock.Tom Lane noticed in code review. Release spinlock before dying.Backpatch to 9.2.Discussion:https://postgr.es/m/87h8vhtgj2.fsf@ansel.ydns.eu
1 parent72d4fd0 commitc9c37e3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

‎src/backend/replication/walreceiver.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,16 @@ WalReceiverMain(void)
175175

176176
/* use volatile pointer to prevent code rearrangement */
177177
volatileWalRcvData*walrcv=WalRcv;
178+
TimestampTznow;
178179

179180
/*
180181
* WalRcv should be set up already (if we are a backend, we inherit this
181182
* by fork() or EXEC_BACKEND mechanism from the postmaster).
182183
*/
183184
Assert(walrcv!=NULL);
184185

186+
now=GetCurrentTimestamp();
187+
185188
/*
186189
* Mark walreceiver as running in shared memory.
187190
*
@@ -209,6 +212,7 @@ WalReceiverMain(void)
209212

210213
caseWALRCV_RUNNING:
211214
/* Shouldn't happen */
215+
SpinLockRelease(&walrcv->mutex);
212216
elog(PANIC,"walreceiver still running according to shared memory state");
213217
}
214218
/* Advertise our PID so that the startup process can kill us */
@@ -220,7 +224,8 @@ WalReceiverMain(void)
220224
startpoint=walrcv->receiveStart;
221225

222226
/* Initialise to a sanish value */
223-
walrcv->lastMsgSendTime=walrcv->lastMsgReceiptTime=walrcv->latestWalEndTime=GetCurrentTimestamp();
227+
walrcv->lastMsgSendTime=
228+
walrcv->lastMsgReceiptTime=walrcv->latestWalEndTime=now;
224229

225230
SpinLockRelease(&walrcv->mutex);
226231

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp