make sure we can call pgsql_conn_cleanup() properly.

This commit is contained in:
Joris Vink 2017-01-10 15:29:03 +01:00
parent ec5e93010f
commit 10929189a0

View File

@ -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);
}