mirror of
https://github.com/jorisvink/kore
synced 2025-03-09 20:49:01 -04:00
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:
|
||||
break;
|
||||
case KORE_PGSQL_STATE_DONE:
|
||||
req->pgsql[i]->state = KORE_PGSQL_STATE_COMPLETE;
|
||||
req->pgsql[i]->conn = NULL;
|
||||
req->flags &= ~HTTP_REQUEST_SLEEPING;
|
||||
req->pgsql[i]->state = KORE_PGSQL_STATE_COMPLETE;
|
||||
|
||||
kore_mem_free(conn->job->query);
|
||||
kore_mem_free(conn->job);
|
||||
@ -190,7 +191,8 @@ kore_pgsql_continue(struct http_request *req, int i)
|
||||
void
|
||||
kore_pgsql_cleanup(struct http_request *req)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
struct pgsql_conn *conn;
|
||||
|
||||
for (i = 0; i < HTTP_PGSQL_MAX; i++) {
|
||||
if (req->pgsql[i] == NULL)
|
||||
@ -204,6 +206,12 @@ kore_pgsql_cleanup(struct http_request *req)
|
||||
if (req->pgsql[i]->error != NULL)
|
||||
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]);
|
||||
req->pgsql[i] = NULL;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user