only remove the pgsql if it was scheduled.

fixes #172.
This commit is contained in:
Joris Vink 2017-01-29 10:34:53 +01:00
parent 829066dc23
commit 1ecb777d41
2 changed files with 6 additions and 2 deletions

View File

@ -24,6 +24,7 @@
#define KORE_PGSQL_SYNC 0x0001
#define KORE_PGSQL_ASYNC 0x0002
#define KORE_PGSQL_SCHEDULED 0x0004
#if defined(__cplusplus)
extern "C" {

View File

@ -432,6 +432,7 @@ pgsql_schedule(struct kore_pgsql *pgsql)
kore_platform_schedule_read(fd, pgsql->conn);
pgsql->state = KORE_PGSQL_STATE_WAIT;
pgsql->flags |= KORE_PGSQL_SCHEDULED;
}
static void
@ -507,8 +508,10 @@ pgsql_conn_release(struct kore_pgsql *pgsql)
/* Async query cleanup */
if (pgsql->flags & KORE_PGSQL_ASYNC) {
if (pgsql->conn != NULL) {
fd = PQsocket(pgsql->conn->db);
kore_platform_disable_read(fd);
if (pgsql->flags & KORE_PGSQL_SCHEDULED) {
fd = PQsocket(pgsql->conn->db);
kore_platform_disable_read(fd);
}
kore_pool_put(&pgsql_job_pool, pgsql->conn->job);
}
}