aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication/walsender.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/replication/walsender.c')
-rw-r--r--src/backend/replication/walsender.c35
1 files changed, 12 insertions, 23 deletions
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 05d2339b150..25fcbca39e9 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -1357,6 +1357,7 @@ ProcessRepliesIfAny(void)
for (;;)
{
+ pq_startmsgread();
r = pq_getbyte_if_available(&firstchar);
if (r < 0)
{
@@ -1369,9 +1370,20 @@ ProcessRepliesIfAny(void)
if (r == 0)
{
/* no data available without blocking */
+ pq_endmsgread();
break;
}
+ /* Read the message contents */
+ resetStringInfo(&reply_message);
+ if (pq_getmessage(&reply_message, 0))
+ {
+ ereport(COMMERROR,
+ (errcode(ERRCODE_PROTOCOL_VIOLATION),
+ errmsg("unexpected EOF on standby connection")));
+ proc_exit(0);
+ }
+
/*
* If we already received a CopyDone from the frontend, the frontend
* should not send us anything until we've closed our end of the COPY.
@@ -1407,16 +1419,6 @@ ProcessRepliesIfAny(void)
streamingDoneSending = true;
}
- /* consume the CopyData message */
- resetStringInfo(&reply_message);
- if (pq_getmessage(&reply_message, 0))
- {
- ereport(COMMERROR,
- (errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("unexpected EOF on standby connection")));
- proc_exit(0);
- }
-
streamingDoneReceiving = true;
received = true;
break;
@@ -1453,19 +1455,6 @@ ProcessStandbyMessage(void)
{
char msgtype;
- resetStringInfo(&reply_message);
-
- /*
- * Read the message contents.
- */
- if (pq_getmessage(&reply_message, 0))
- {
- ereport(COMMERROR,
- (errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("unexpected EOF on standby connection")));
- proc_exit(0);
- }
-
/*
* Check message type from the first byte.
*/