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