mirror of https://git.kore.io/kore.git
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.
This commit is contained in:
parent
b54b93536d
commit
f3b7cba58c
17
src/pgsql.c
17
src/pgsql.c
|
@ -632,6 +632,12 @@ pgsql_conn_create(struct kore_pgsql *pgsql, struct pgsql_db *db)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PQsetnonblocking(conn->db, 1) == -1) {
|
||||||
|
pgsql_set_error(pgsql, PQerrorMessage(conn->db));
|
||||||
|
pgsql_conn_cleanup(conn);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
return (conn);
|
return (conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -715,8 +721,15 @@ pgsql_read_result(struct kore_pgsql *pgsql)
|
||||||
PGnotify *notify;
|
PGnotify *notify;
|
||||||
|
|
||||||
if (PQisBusy(pgsql->conn->db)) {
|
if (PQisBusy(pgsql->conn->db)) {
|
||||||
pgsql->state = KORE_PGSQL_STATE_WAIT;
|
if (!PQconsumeInput(pgsql->conn->db)) {
|
||||||
return;
|
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) {
|
while ((notify = PQnotifies(pgsql->conn->db)) != NULL) {
|
||||||
|
|
Loading…
Reference in New Issue