@@ -1719,7 +1719,12 @@ ProcessRepliesIfAny(void)
1719
1719
1720
1720
last_processing = GetCurrentTimestamp ();
1721
1721
1722
- for (;;)
1722
+ /*
1723
+ * If we already received a CopyDone from the frontend, any subsequent
1724
+ * message is the beginning of a new command, and should be processed in
1725
+ * the main processing loop.
1726
+ */
1727
+ while (!streamingDoneReceiving )
1723
1728
{
1724
1729
pq_startmsgread ();
1725
1730
r = pq_getbyte_if_available (& firstchar );
@@ -1748,19 +1753,6 @@ ProcessRepliesIfAny(void)
1748
1753
proc_exit (0 );
1749
1754
}
1750
1755
1751
- /*
1752
- * If we already received a CopyDone from the frontend, the frontend
1753
- * should not send us anything until we've closed our end of the COPY.
1754
- * XXX: In theory, the frontend could already send the next command
1755
- * before receiving the CopyDone, but libpq doesn't currently allow
1756
- * that.
1757
- */
1758
- if (streamingDoneReceiving && firstchar != 'X' )
1759
- ereport (FATAL ,
1760
- (errcode (ERRCODE_PROTOCOL_VIOLATION ),
1761
- errmsg ("unexpected standby message type \"%c\", after receiving CopyDone" ,
1762
- firstchar )));
1763
-
1764
1756
/* Handle the very limited subset of commands expected in this phase */
1765
1757
switch (firstchar )
1766
1758
{
@@ -2362,8 +2354,10 @@ WalSndLoop(WalSndSendDataCallback send_data)
2362
2354
long sleeptime ;
2363
2355
int wakeEvents ;
2364
2356
2365
- wakeEvents = WL_LATCH_SET | WL_EXIT_ON_PM_DEATH | WL_TIMEOUT |
2366
- WL_SOCKET_READABLE ;
2357
+ wakeEvents = WL_LATCH_SET | WL_EXIT_ON_PM_DEATH | WL_TIMEOUT ;
2358
+
2359
+ if (!streamingDoneReceiving )
2360
+ wakeEvents |= WL_SOCKET_READABLE ;
2367
2361
2368
2362
/*
2369
2363
* Use fresh timestamp, not last_processing, to reduce the chance
0 commit comments