diff options
author | Tatsuo Ishii <ishii@postgresql.org> | 2002-10-07 05:10:02 +0000 |
---|---|---|
committer | Tatsuo Ishii <ishii@postgresql.org> | 2002-10-07 05:10:02 +0000 |
commit | 9a2e9c680447486914bcff60eaa92086e8b1da25 (patch) | |
tree | 6b85d7c55275717537f10f7fab23807c77716361 | |
parent | e4c2967edb09cd2c9918a2ef9c5ee636ef40cb52 (diff) |
Avoid PQisBusy/PQconsumeInput busy loop in case of PQisBusy returning
false. per Tom Lane's suggestion. See:
Subject: Suggested change to pgbench
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tatsuo Ishii <t-ishii@sra.co.jp>
Cc: pgsql-patches@postgreSQL.org
Date: Sun, 06 Oct 2002 12:37:27 -0400
for more details.
-rw-r--r-- | contrib/pgbench/pgbench.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c index 4eb81ec544c..2eadf625419 100644 --- a/contrib/pgbench/pgbench.c +++ b/contrib/pgbench/pgbench.c @@ -1,5 +1,5 @@ /* - * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.19 2002/09/04 20:31:08 momjian Exp $ + * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.20 2002/10/07 05:10:02 ishii Exp $ * * pgbench: a simple TPC-B like benchmark program for PostgreSQL * written by Tatsuo Ishii @@ -184,17 +184,16 @@ doOne(CState * state, int n, int debug, int ttype) { /* are we receiver? */ if (debug) fprintf(stderr, "client %d receiving\n", n); - while (PQisBusy(st->con) == TRUE) - { - if (!PQconsumeInput(st->con)) - { /* there's something wrong */ - fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n", n, st->state); - remains--; /* I've aborted */ - PQfinish(st->con); - st->con = NULL; - return; - } + if (!PQconsumeInput(st->con)) + { /* there's something wrong */ + fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n", n, st->state); + remains--; /* I've aborted */ + PQfinish(st->con); + st->con = NULL; + return; } + if (PQisBusy(st->con)) + return; /* don't have the whole result yet */ switch (st->state) { @@ -367,17 +366,16 @@ doSelectOnly(CState * state, int n, int debug) { /* are we receiver? */ if (debug) fprintf(stderr, "client %d receiving\n", n); - while (PQisBusy(st->con) == TRUE) - { - if (!PQconsumeInput(st->con)) - { /* there's something wrong */ - fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n", n, st->state); - remains--; /* I've aborted */ - PQfinish(st->con); - st->con = NULL; - return; - } + if (!PQconsumeInput(st->con)) + { /* there's something wrong */ + fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n", n, st->state); + remains--; /* I've aborted */ + PQfinish(st->con); + st->con = NULL; + return; } + if (PQisBusy(st->con)) + return; /* don't have the whole result yet */ switch (st->state) { |