commit 27d174694022bf6549d2e20deab3f1e7319a3544
parent 2e321f14de71814f5251d1365058882da13432b0
Author: Joris Vink <joris@coders.se>
Date: Wed, 18 Jul 2018 11:40:59 +0200
Consume all notifications on a connection.
Diffstat:
src/pgsql.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/src/pgsql.c b/src/pgsql.c
@@ -384,9 +384,6 @@ kore_pgsql_cleanup(struct kore_pgsql *pgsql)
if (pgsql->conn != NULL)
pgsql_conn_release(pgsql);
- kore_free(pgsql->notify.extra);
- kore_free(pgsql->notify.channel);
-
pgsql->result = NULL;
pgsql->error = NULL;
pgsql->conn = NULL;
@@ -712,18 +709,14 @@ pgsql_read_result(struct kore_pgsql *pgsql)
}
while ((notify = PQnotifies(pgsql->conn->db)) != NULL) {
- kore_free(pgsql->notify.extra);
- kore_free(pgsql->notify.channel);
pgsql->state = KORE_PGSQL_STATE_NOTIFY;
- pgsql->notify.channel = kore_strdup(notify->relname);
+ pgsql->notify.extra = notify->extra;
+ pgsql->notify.channel = notify->relname;
- if (notify->extra != NULL)
- pgsql->notify.extra = kore_strdup(notify->extra);
- else
- pgsql->notify.extra = NULL;
+ if (pgsql->cb != NULL)
+ pgsql->cb(pgsql, pgsql->arg);
PQfreemem(notify);
- return;
}
pgsql->result = PQgetResult(pgsql->conn->db);