commit 1ecb777d411ee2091d2bf8079ba9901bfef3c801
parent 829066dc2390bc80e807e1f9164d6a0d1c0525ce
Author: Joris Vink <joris@coders.se>
Date: Sun, 29 Jan 2017 10:34:53 +0100
only remove the pgsql if it was scheduled.
fixes #172.
Diffstat:
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/includes/pgsql.h b/includes/pgsql.h
@@ -24,6 +24,7 @@
#define KORE_PGSQL_SYNC 0x0001
#define KORE_PGSQL_ASYNC 0x0002
+#define KORE_PGSQL_SCHEDULED 0x0004
#if defined(__cplusplus)
extern "C" {
diff --git a/src/pgsql.c b/src/pgsql.c
@@ -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);
}
}