diff options
-rw-r--r-- | contrib/pgbench/pgbench.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c index 693dbc3934b..6c36ad2528a 100644 --- a/contrib/pgbench/pgbench.c +++ b/contrib/pgbench/pgbench.c @@ -3231,7 +3231,7 @@ threadRun(void *arg) sock = PQsocket(st->con); if (sock < 0) { - fprintf(stderr, "bad socket: %s\n", strerror(errno)); + fprintf(stderr, "bad socket: %s", PQerrorMessage(st->con)); goto done; } @@ -3299,11 +3299,21 @@ threadRun(void *arg) Command **commands = sql_files[st->use_file]; int prev_ecnt = st->ecnt; - if (st->con && (FD_ISSET(PQsocket(st->con), &input_mask) - || commands[st->state]->type == META_COMMAND)) + if (st->con) { - if (!doCustom(thread, st, &result->conn_time, logfile, &aggs)) - remains--; /* I've aborted */ + int sock = PQsocket(st->con); + + if (sock < 0) + { + fprintf(stderr, "bad socket: %s", PQerrorMessage(st->con)); + goto done; + } + if (FD_ISSET(sock, &input_mask) || + commands[st->state]->type == META_COMMAND) + { + if (!doCustom(thread, st, &result->conn_time, logfile, &aggs)) + remains--; /* I've aborted */ + } } if (st->ecnt > prev_ecnt && commands[st->state]->type == META_COMMAND) |