diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-11-17 08:38:55 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-11-17 08:39:01 +0100 |
commit | c5a7ce5d22f57e3a248ae3e9bc4541a35495b8a1 (patch) | |
tree | 5dbdcae0edd65ad373cd637e9ac88e27af3c826a | |
parent | 84a1ac1baf0cdec49a2600f1872337612233ed01 (diff) | |
download | gnunet-c5a7ce5d22f57e3a248ae3e9bc4541a35495b8a1.tar.gz gnunet-c5a7ce5d22f57e3a248ae3e9bc4541a35495b8a1.zip |
subscribes are not reference counted by postgres, only subscribe/unsubscribe once per connection
-rw-r--r-- | src/pq/pq_event.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/pq/pq_event.c b/src/pq/pq_event.c index 79a2e80c6..283e4569c 100644 --- a/src/pq/pq_event.c +++ b/src/pq/pq_event.c | |||
@@ -420,6 +420,7 @@ GNUNET_PQ_event_listen (struct GNUNET_PQ_Context *db, | |||
420 | void *cb_cls) | 420 | void *cb_cls) |
421 | { | 421 | { |
422 | struct GNUNET_DB_EventHandler *eh; | 422 | struct GNUNET_DB_EventHandler *eh; |
423 | bool sub; | ||
423 | 424 | ||
424 | eh = GNUNET_new (struct GNUNET_DB_EventHandler); | 425 | eh = GNUNET_new (struct GNUNET_DB_EventHandler); |
425 | eh->db = db; | 426 | eh->db = db; |
@@ -427,6 +428,9 @@ GNUNET_PQ_event_listen (struct GNUNET_PQ_Context *db, | |||
427 | &eh->sh); | 428 | &eh->sh); |
428 | eh->cb = cb; | 429 | eh->cb = cb; |
429 | eh->cb_cls = cb_cls; | 430 | eh->cb_cls = cb_cls; |
431 | sub = (NULL == | ||
432 | GNUNET_CONTAINER_multishortmap_get (db->channel_map, | ||
433 | &eh->sh)); | ||
430 | GNUNET_assert (GNUNET_OK == | 434 | GNUNET_assert (GNUNET_OK == |
431 | GNUNET_CONTAINER_multishortmap_put (db->channel_map, | 435 | GNUNET_CONTAINER_multishortmap_put (db->channel_map, |
432 | &eh->sh, | 436 | &eh->sh, |
@@ -439,9 +443,10 @@ GNUNET_PQ_event_listen (struct GNUNET_PQ_Context *db, | |||
439 | scheduler_fd_cb (db, | 443 | scheduler_fd_cb (db, |
440 | PQsocket (db->conn)); | 444 | PQsocket (db->conn)); |
441 | } | 445 | } |
442 | manage_subscribe (db, | 446 | if (sub) |
443 | "LISTEN X", | 447 | manage_subscribe (db, |
444 | eh); | 448 | "LISTEN X", |
449 | eh); | ||
445 | eh->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, | 450 | eh->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, |
446 | &event_timeout, | 451 | &event_timeout, |
447 | eh); | 452 | eh); |
@@ -458,9 +463,12 @@ GNUNET_PQ_event_listen_cancel (struct GNUNET_DB_EventHandler *eh) | |||
458 | GNUNET_CONTAINER_multishortmap_remove (db->channel_map, | 463 | GNUNET_CONTAINER_multishortmap_remove (db->channel_map, |
459 | &eh->sh, | 464 | &eh->sh, |
460 | eh)); | 465 | eh)); |
461 | manage_subscribe (db, | 466 | if (NULL == |
462 | "UNLISTEN X", | 467 | GNUNET_CONTAINER_multishortmap_get (db->channel_map, |
463 | eh); | 468 | &eh->sh)) |
469 | manage_subscribe (db, | ||
470 | "UNLISTEN X", | ||
471 | eh); | ||
464 | if (0 == GNUNET_CONTAINER_multishortmap_size (db->channel_map)) | 472 | if (0 == GNUNET_CONTAINER_multishortmap_size (db->channel_map)) |
465 | { | 473 | { |
466 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 474 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |