@@ -1440,7 +1440,12 @@ ProcessRepliesIfAny(void)
1440
1440
1441
1441
last_processing = GetCurrentTimestamp ();
1442
1442
1443
- for (;;)
1443
+ /*
1444
+ * If we already received a CopyDone from the frontend, any subsequent
1445
+ * message is the beginning of a new command, and should be processed in
1446
+ * the main processing loop.
1447
+ */
1448
+ while (!streamingDoneReceiving )
1444
1449
{
1445
1450
pq_startmsgread ();
1446
1451
r = pq_getbyte_if_available (& firstchar );
@@ -1469,19 +1474,6 @@ ProcessRepliesIfAny(void)
1469
1474
proc_exit (0 );
1470
1475
}
1471
1476
1472
- /*
1473
- * If we already received a CopyDone from the frontend, the frontend
1474
- * should not send us anything until we've closed our end of the COPY.
1475
- * XXX: In theory, the frontend could already send the next command
1476
- * before receiving the CopyDone, but libpq doesn't currently allow
1477
- * that.
1478
- */
1479
- if (streamingDoneReceiving && firstchar != 'X' )
1480
- ereport (FATAL ,
1481
- (errcode (ERRCODE_PROTOCOL_VIOLATION ),
1482
- errmsg ("unexpected standby message type \"%c\", after receiving CopyDone" ,
1483
- firstchar )));
1484
-
1485
1477
/* Handle the very limited subset of commands expected in this phase */
1486
1478
switch (firstchar )
1487
1479
{
@@ -1963,8 +1955,10 @@ WalSndLoop(WalSndSendDataCallback send_data)
1963
1955
long sleeptime ;
1964
1956
int wakeEvents ;
1965
1957
1966
- wakeEvents = WL_LATCH_SET | WL_POSTMASTER_DEATH | WL_TIMEOUT |
1967
- WL_SOCKET_READABLE ;
1958
+ wakeEvents = WL_LATCH_SET | WL_POSTMASTER_DEATH | WL_TIMEOUT ;
1959
+
1960
+ if (!streamingDoneReceiving )
1961
+ wakeEvents |= WL_SOCKET_READABLE ;
1968
1962
1969
1963
/*
1970
1964
* Use fresh timestamp, not last_processed, to reduce the chance
0 commit comments