Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9a2e9c6

Browse files
committed
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.
1 parent e4c2967 commit 9a2e9c6

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

contrib/pgbench/pgbench.c

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.19 2002/09/04 20:31:08 momjian Exp $
2+
* $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.20 2002/10/07 05:10:02 ishii Exp $
33
*
44
* pgbench: a simple TPC-B like benchmark program for PostgreSQL
55
* written by Tatsuo Ishii
@@ -184,17 +184,16 @@ doOne(CState * state, int n, int debug, int ttype)
184184
{ /* are we receiver? */
185185
if (debug)
186186
fprintf(stderr, "client %d receiving\n", n);
187-
while (PQisBusy(st->con) == TRUE)
188-
{
189-
if (!PQconsumeInput(st->con))
190-
{ /* there's something wrong */
191-
fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n", n, st->state);
192-
remains--; /* I've aborted */
193-
PQfinish(st->con);
194-
st->con = NULL;
195-
return;
196-
}
187+
if (!PQconsumeInput(st->con))
188+
{ /* there's something wrong */
189+
fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n", n, st->state);
190+
remains--; /* I've aborted */
191+
PQfinish(st->con);
192+
st->con = NULL;
193+
return;
197194
}
195+
if (PQisBusy(st->con))
196+
return; /* don't have the whole result yet */
198197

199198
switch (st->state)
200199
{
@@ -367,17 +366,16 @@ doSelectOnly(CState * state, int n, int debug)
367366
{ /* are we receiver? */
368367
if (debug)
369368
fprintf(stderr, "client %d receiving\n", n);
370-
while (PQisBusy(st->con) == TRUE)
371-
{
372-
if (!PQconsumeInput(st->con))
373-
{ /* there's something wrong */
374-
fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n", n, st->state);
375-
remains--; /* I've aborted */
376-
PQfinish(st->con);
377-
st->con = NULL;
378-
return;
379-
}
369+
if (!PQconsumeInput(st->con))
370+
{ /* there's something wrong */
371+
fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n", n, st->state);
372+
remains--; /* I've aborted */
373+
PQfinish(st->con);
374+
st->con = NULL;
375+
return;
380376
}
377+
if (PQisBusy(st->con))
378+
return; /* don't have the whole result yet */
381379

382380
switch (st->state)
383381
{

0 commit comments

Comments
 (0)