bool first_stream;
WalRcvData *walrcv = WalRcv;
TimestampTz last_recv_timestamp;
+ TimestampTz now;
bool ping_sent;
char *err;
*/
Assert(walrcv != NULL);
+ now = GetCurrentTimestamp();
+
/*
* Mark walreceiver as running in shared memory.
*
case WALRCV_RESTARTING:
default:
/* Shouldn't happen */
+ SpinLockRelease(&walrcv->mutex);
elog(PANIC, "walreceiver still running according to shared memory state");
}
/* Advertise our PID so that the startup process can kill us */
startpointTLI = walrcv->receiveStartTLI;
/* Initialise to a sanish value */
- walrcv->lastMsgSendTime = walrcv->lastMsgReceiptTime = walrcv->latestWalEndTime = GetCurrentTimestamp();
+ walrcv->lastMsgSendTime =
+ walrcv->lastMsgReceiptTime = walrcv->latestWalEndTime = now;
SpinLockRelease(&walrcv->mutex);
SpinLockAcquire(&walrcv->mutex);
memset(walrcv->conninfo, 0, MAXCONNINFO);
if (tmp_conninfo)
- {
strlcpy((char *) walrcv->conninfo, tmp_conninfo, MAXCONNINFO);
- pfree(tmp_conninfo);
- }
walrcv->ready_to_display = true;
SpinLockRelease(&walrcv->mutex);
+ if (tmp_conninfo)
+ pfree(tmp_conninfo);
+
first_stream = true;
for (;;)
{
TimestampTz last_receipt_time;
XLogRecPtr latest_end_lsn;
TimestampTz latest_end_time;
- char *slotname;
- char *conninfo;
+ char slotname[NAMEDATALEN];
+ char conninfo[MAXCONNINFO];
/* Take a lock to ensure value consistency */
SpinLockAcquire(&WalRcv->mutex);
last_receipt_time = WalRcv->lastMsgReceiptTime;
latest_end_lsn = WalRcv->latestWalEnd;
latest_end_time = WalRcv->latestWalEndTime;
- slotname = pstrdup(WalRcv->slotname);
- conninfo = pstrdup(WalRcv->conninfo);
+ strlcpy(slotname, (char *) WalRcv->slotname, sizeof(slotname));
+ strlcpy(conninfo, (char *) WalRcv->conninfo, sizeof(conninfo));
SpinLockRelease(&WalRcv->mutex);
/*