commit 10929189a096a0f06136928850071b0f371357e5
parent ec5e93010f733077fdde91f4f2f7194673837fef
Author: Joris Vink <joris@coders.se>
Date: Tue, 10 Jan 2017 15:29:03 +0100
make sure we can call pgsql_conn_cleanup() properly.
Diffstat:
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git 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);
}