|
23 | 23 | * Portions Copyright (c) 1994, Regents of the University of California
|
24 | 24 | *
|
25 | 25 | * IDENTIFICATION
|
26 |
| - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.102 2003/08/08 21:42:55 momjian Exp $ |
| 26 | + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.103 2003/10/19 21:36:41 tgl Exp $ |
27 | 27 | *
|
28 | 28 | *-------------------------------------------------------------------------
|
29 | 29 | */
|
@@ -828,7 +828,24 @@ pqSendSome(PGconn *conn, int len)
|
828 | 828 | break;
|
829 | 829 | }
|
830 | 830 |
|
831 |
| - if (pqWait(FALSE, TRUE, conn)) |
| 831 | + /* |
| 832 | + * There are scenarios in which we can't send data because the |
| 833 | + * communications channel is full, but we cannot expect the server |
| 834 | + * to clear the channel eventually because it's blocked trying to |
| 835 | + * send data to us. (This can happen when we are sending a large |
| 836 | + * amount of COPY data, and the server has generated lots of |
| 837 | + * NOTICE responses.) To avoid a deadlock situation, we must be |
| 838 | + * prepared to accept and buffer incoming data before we try |
| 839 | + * again. Furthermore, it is possible that such incoming data |
| 840 | + * might not arrive until after we've gone to sleep. Therefore, |
| 841 | + * we wait for either read ready or write ready. |
| 842 | + */ |
| 843 | + if (pqReadData(conn) < 0) |
| 844 | + { |
| 845 | + result = -1; /* error message already set up */ |
| 846 | + break; |
| 847 | + } |
| 848 | + if (pqWait(TRUE, TRUE, conn)) |
832 | 849 | {
|
833 | 850 | result = -1;
|
834 | 851 | break;
|
|
0 commit comments