kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit f3b7cba58cc8051997b9b072243c8553c6d23b6a
parent b54b93536d177ded1f2935c76c533dc1d83b70c1
Author: Joris Vink <joris@coders.se>
Date:   Wed,  4 Sep 2019 19:19:52 +0200

Call PQConsumeInput() again after PQisBusy().

Prevents a stall in case there is still data in the read end of the socket
but PQisBusy() told us to not fetch a result yet. In that case we end up
stalling due to epoll not giving us another EPOLLIN event due to EPOLLET.

Diffstat:
src/pgsql.c | 17+++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/pgsql.c b/src/pgsql.c @@ -632,6 +632,12 @@ pgsql_conn_create(struct kore_pgsql *pgsql, struct pgsql_db *db) return (NULL); } + if (PQsetnonblocking(conn->db, 1) == -1) { + pgsql_set_error(pgsql, PQerrorMessage(conn->db)); + pgsql_conn_cleanup(conn); + return (NULL); + } + return (conn); } @@ -715,8 +721,15 @@ pgsql_read_result(struct kore_pgsql *pgsql) PGnotify *notify; if (PQisBusy(pgsql->conn->db)) { - pgsql->state = KORE_PGSQL_STATE_WAIT; - return; + if (!PQconsumeInput(pgsql->conn->db)) { + pgsql->state = KORE_PGSQL_STATE_ERROR; + pgsql->error = kore_strdup( + PQerrorMessage(pgsql->conn->db)); + return; + } else if (PQisBusy(pgsql->conn->db)) { + pgsql->state = KORE_PGSQL_STATE_WAIT; + return; + } } while ((notify = PQnotifies(pgsql->conn->db)) != NULL) {