mirror of https://git.kore.io/kore.git
pgsql_conn improvements.
set conn inside kore_pgsql to NULL when we've completed. if at kore_pgsql_cleanup() time the conn is still there we'll drain it as per documentation.
This commit is contained in:
parent
6eb091c77c
commit
a431f76263
|
@ -165,8 +165,9 @@ kore_pgsql_continue(struct http_request *req, int i)
|
||||||
case KORE_PGSQL_STATE_WAIT:
|
case KORE_PGSQL_STATE_WAIT:
|
||||||
break;
|
break;
|
||||||
case KORE_PGSQL_STATE_DONE:
|
case KORE_PGSQL_STATE_DONE:
|
||||||
req->pgsql[i]->state = KORE_PGSQL_STATE_COMPLETE;
|
req->pgsql[i]->conn = NULL;
|
||||||
req->flags &= ~HTTP_REQUEST_SLEEPING;
|
req->flags &= ~HTTP_REQUEST_SLEEPING;
|
||||||
|
req->pgsql[i]->state = KORE_PGSQL_STATE_COMPLETE;
|
||||||
|
|
||||||
kore_mem_free(conn->job->query);
|
kore_mem_free(conn->job->query);
|
||||||
kore_mem_free(conn->job);
|
kore_mem_free(conn->job);
|
||||||
|
@ -190,7 +191,8 @@ kore_pgsql_continue(struct http_request *req, int i)
|
||||||
void
|
void
|
||||||
kore_pgsql_cleanup(struct http_request *req)
|
kore_pgsql_cleanup(struct http_request *req)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
struct pgsql_conn *conn;
|
||||||
|
|
||||||
for (i = 0; i < HTTP_PGSQL_MAX; i++) {
|
for (i = 0; i < HTTP_PGSQL_MAX; i++) {
|
||||||
if (req->pgsql[i] == NULL)
|
if (req->pgsql[i] == NULL)
|
||||||
|
@ -204,6 +206,12 @@ kore_pgsql_cleanup(struct http_request *req)
|
||||||
if (req->pgsql[i]->error != NULL)
|
if (req->pgsql[i]->error != NULL)
|
||||||
kore_mem_free(req->pgsql[i]->error);
|
kore_mem_free(req->pgsql[i]->error);
|
||||||
|
|
||||||
|
if (req->pgsql[i]->conn != NULL) {
|
||||||
|
conn = req->pgsql[i]->conn;
|
||||||
|
while (PQgetResult(conn->db) != NULL)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
kore_mem_free(req->pgsql[i]);
|
kore_mem_free(req->pgsql[i]);
|
||||||
req->pgsql[i] = NULL;
|
req->pgsql[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue