diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-10-19 21:36:41 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-10-19 21:36:41 +0000 |
commit | 9dfdbef345390124eaf993f6289e8ae796aa6918 (patch) | |
tree | 43791a5127da2fb3b166131ae1868ab662ba8cfe /src/interfaces/libpq/fe-exec.c | |
parent | d5353acbc37e8043172855f8c148c96ae1694e61 (diff) | |
download | postgresql-9dfdbef345390124eaf993f6289e8ae796aa6918.tar.gz postgresql-9dfdbef345390124eaf993f6289e8ae796aa6918.zip |
Adjust libpq to avoid deadlock when both client and server want to send
data, and both have filled the transmission buffers. One scenario where
this can happen was illustrated here:
http://archives.postgresql.org/pgsql-hackers/2003-04/msg00979.php
Diffstat (limited to 'src/interfaces/libpq/fe-exec.c')
-rw-r--r-- | src/interfaces/libpq/fe-exec.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 810a753ed3c..1967d7429b4 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.151 2003/10/04 21:05:21 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.152 2003/10/19 21:36:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1336,6 +1336,17 @@ PQputCopyData(PGconn *conn, const char *buffer, int nbytes) libpq_gettext("no COPY in progress\n")); return -1; } + + /* + * Check for NOTICE messages coming back from the server. Since the + * server might generate multiple notices during the COPY, we have to + * consume those in a reasonably prompt fashion to prevent the comm + * buffers from filling up and possibly blocking the server. + */ + if (!PQconsumeInput(conn)) + return -1; /* I/O failure */ + parseInput(conn); + if (nbytes > 0) { /* |