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

Commitb24f15f

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 parentd149aa7 commitb24f15f

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
@@ -195,6 +195,7 @@ WalReceiverMain(void)
195195
/* use volatile pointer to prevent code rearrangement */
196196
volatileWalRcvData*walrcv=WalRcv;
197197
TimestampTzlast_recv_timestamp;
198+
TimestampTznow;
198199
boolping_sent;
199200

200201
/*
@@ -203,6 +204,8 @@ WalReceiverMain(void)
203204
*/
204205
Assert(walrcv!=NULL);
205206

207+
now=GetCurrentTimestamp();
208+
206209
/*
207210
* Mark walreceiver as running in shared memory.
208211
*
@@ -233,6 +236,7 @@ WalReceiverMain(void)
233236
caseWALRCV_RESTARTING:
234237
default:
235238
/* Shouldn't happen */
239+
SpinLockRelease(&walrcv->mutex);
236240
elog(PANIC,"walreceiver still running according to shared memory state");
237241
}
238242
/* Advertise our PID so that the startup process can kill us */
@@ -245,7 +249,8 @@ WalReceiverMain(void)
245249
startpointTLI=walrcv->receiveStartTLI;
246250

247251
/* Initialise to a sanish value */
248-
walrcv->lastMsgSendTime=walrcv->lastMsgReceiptTime=walrcv->latestWalEndTime=GetCurrentTimestamp();
252+
walrcv->lastMsgSendTime=
253+
walrcv->lastMsgReceiptTime=walrcv->latestWalEndTime=now;
249254

250255
SpinLockRelease(&walrcv->mutex);
251256

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp