Consume all notifications on a connection.

This commit is contained in:
Joris Vink 2018-07-18 11:40:59 +02:00
parent 2e321f14de
commit 27d1746940
1 changed files with 4 additions and 11 deletions

View File

@ -384,9 +384,6 @@ kore_pgsql_cleanup(struct kore_pgsql *pgsql)
if (pgsql->conn != NULL) if (pgsql->conn != NULL)
pgsql_conn_release(pgsql); pgsql_conn_release(pgsql);
kore_free(pgsql->notify.extra);
kore_free(pgsql->notify.channel);
pgsql->result = NULL; pgsql->result = NULL;
pgsql->error = NULL; pgsql->error = NULL;
pgsql->conn = NULL; pgsql->conn = NULL;
@ -712,18 +709,14 @@ pgsql_read_result(struct kore_pgsql *pgsql)
} }
while ((notify = PQnotifies(pgsql->conn->db)) != NULL) { while ((notify = PQnotifies(pgsql->conn->db)) != NULL) {
kore_free(pgsql->notify.extra);
kore_free(pgsql->notify.channel);
pgsql->state = KORE_PGSQL_STATE_NOTIFY; 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) if (pgsql->cb != NULL)
pgsql->notify.extra = kore_strdup(notify->extra); pgsql->cb(pgsql, pgsql->arg);
else
pgsql->notify.extra = NULL;
PQfreemem(notify); PQfreemem(notify);
return;
} }
pgsql->result = PQgetResult(pgsql->conn->db); pgsql->result = PQgetResult(pgsql->conn->db);