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 f021c8db44b41aaaaf1a57155cbfcc93d4c06df3
parent 0b3c918ba620b887370621cd8c7a1ab471731c58
Author: Joris Vink <joris@coders.se>
Date:   Thu, 14 Aug 2014 16:43:40 +0200

pgsql improvements

* set pgsql->result to NULL when we freed it
* drain the connection pipe just in case in pgsql_conn_release()

Diffstat:
src/pgsql.c | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/pgsql.c b/src/pgsql.c @@ -147,8 +147,10 @@ kore_pgsql_continue(struct http_request *req, struct kore_pgsql *pgsql) pgsql->error = NULL; } - if (pgsql->result) + if (pgsql->result) { PQclear(pgsql->result); + pgsql->result = NULL; + } switch (pgsql->state) { case KORE_PGSQL_STATE_INIT: @@ -246,6 +248,10 @@ pgsql_conn_release(struct kore_pgsql *pgsql) kore_mem_free(pgsql->conn->job->query); kore_mem_free(pgsql->conn->job); + /* Drain just in case. */ + while (PQgetResult(pgsql->conn->db) != NULL) + ; + pgsql->conn->job = NULL; pgsql->conn->flags |= PGSQL_CONN_FREE; TAILQ_INSERT_TAIL(&pgsql_conn_free, pgsql->conn, list);