From 27d174694022bf6549d2e20deab3f1e7319a3544 Mon Sep 17 00:00:00 2001 From: Joris Vink Date: Wed, 18 Jul 2018 11:40:59 +0200 Subject: [PATCH] Consume all notifications on a connection. --- src/pgsql.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/pgsql.c b/src/pgsql.c index d97f485..1f73b8d 100644 --- 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);