@@ -1707,7 +1707,12 @@ ProcessRepliesIfAny(void)
1707
1707
1708
1708
last_processing = GetCurrentTimestamp ();
1709
1709
1710
- for (;;)
1710
+ /*
1711
+ * If we already received a CopyDone from the frontend, any subsequent
1712
+ * message is the beginning of a new command, and should be processed in
1713
+ * the main processing loop.
1714
+ */
1715
+ while (!streamingDoneReceiving )
1711
1716
{
1712
1717
pq_startmsgread ();
1713
1718
r = pq_getbyte_if_available (& firstchar );
@@ -1736,19 +1741,6 @@ ProcessRepliesIfAny(void)
1736
1741
proc_exit (0 );
1737
1742
}
1738
1743
1739
- /*
1740
- * If we already received a CopyDone from the frontend, the frontend
1741
- * should not send us anything until we've closed our end of the COPY.
1742
- * XXX: In theory, the frontend could already send the next command
1743
- * before receiving the CopyDone, but libpq doesn't currently allow
1744
- * that.
1745
- */
1746
- if (streamingDoneReceiving && firstchar != 'X' )
1747
- ereport (FATAL ,
1748
- (errcode (ERRCODE_PROTOCOL_VIOLATION ),
1749
- errmsg ("unexpected standby message type \"%c\", after receiving CopyDone" ,
1750
- firstchar )));
1751
-
1752
1744
/* Handle the very limited subset of commands expected in this phase */
1753
1745
switch (firstchar )
1754
1746
{
@@ -2349,8 +2341,10 @@ WalSndLoop(WalSndSendDataCallback send_data)
2349
2341
long sleeptime ;
2350
2342
int wakeEvents ;
2351
2343
2352
- wakeEvents = WL_LATCH_SET | WL_EXIT_ON_PM_DEATH | WL_TIMEOUT |
2353
- WL_SOCKET_READABLE ;
2344
+ wakeEvents = WL_LATCH_SET | WL_EXIT_ON_PM_DEATH | WL_TIMEOUT ;
2345
+
2346
+ if (!streamingDoneReceiving )
2347
+ wakeEvents |= WL_SOCKET_READABLE ;
2354
2348
2355
2349
/*
2356
2350
* Use fresh timestamp, not last_processing, to reduce the chance
0 commit comments