From 10929189a096a0f06136928850071b0f371357e5 Mon Sep 17 00:00:00 2001 From: Joris Vink Date: Tue, 10 Jan 2017 15:29:03 +0100 Subject: [PATCH] make sure we can call pgsql_conn_cleanup() properly. --- src/pgsql.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pgsql.c b/src/pgsql.c index 165c541..1cf6bb8 100644 --- a/src/pgsql.c +++ b/src/pgsql.c @@ -476,7 +476,14 @@ pgsql_conn_create(struct kore_pgsql *pgsql, struct pgsql_db *db) fatal("pgsql_conn_create: no connection string"); pgsql_conn_count++; + conn = kore_malloc(sizeof(*conn)); + conn->job = NULL; + conn->flags = PGSQL_CONN_FREE; + conn->type = KORE_TYPE_PGSQL_CONN; + conn->name = kore_strdup(db->name); + TAILQ_INSERT_TAIL(&pgsql_conn_free, conn, list); + kore_debug("pgsql_conn_create(): %p", conn); conn->db = PQconnectdb(db->conn_string); @@ -486,12 +493,6 @@ pgsql_conn_create(struct kore_pgsql *pgsql, struct pgsql_db *db) return (NULL); } - conn->job = NULL; - conn->flags = PGSQL_CONN_FREE; - conn->type = KORE_TYPE_PGSQL_CONN; - conn->name = kore_strdup(db->name); - TAILQ_INSERT_TAIL(&pgsql_conn_free, conn, list); - return (conn); }