summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2014-10-14 18:27:55 +0200
committerMichal Schmidt <mschmidt@redhat.com>2014-10-23 17:38:02 +0200
commitc9fe4af70d2c884c1f95714a81ad6d1de31d5186 (patch)
tree0c690f38ba2c23372b45c54e77db51b78807ac07
parentc1f906bd91c388fd84a006a56e1e6692e23f8ae3 (diff)
sd-bus: make sd_bus::reply_callbacks a OrderedHashmap
The way process_closing() picks the first entry from reply_callbacks and works with it makes it likely that it cares about the order.
-rw-r--r--src/libsystemd/sd-bus/bus-internal.h2
-rw-r--r--src/libsystemd/sd-bus/bus-slot.c2
-rw-r--r--src/libsystemd/sd-bus/sd-bus.c14
3 files changed, 9 insertions, 9 deletions
diff --git a/src/libsystemd/sd-bus/bus-internal.h b/src/libsystemd/sd-bus/bus-internal.h
index 601ea5afb1..57247d7df9 100644
--- a/src/libsystemd/sd-bus/bus-internal.h
+++ b/src/libsystemd/sd-bus/bus-internal.h
@@ -230,7 +230,7 @@ struct sd_bus {
struct bus_match_node match_callbacks;
Prioq *reply_callbacks_prioq;
- Hashmap *reply_callbacks;
+ OrderedHashmap *reply_callbacks;
LIST_HEAD(struct filter_callback, filter_callbacks);
Hashmap *nodes;
diff --git a/src/libsystemd/sd-bus/bus-slot.c b/src/libsystemd/sd-bus/bus-slot.c
index d6793c29e9..568a6ed60c 100644
--- a/src/libsystemd/sd-bus/bus-slot.c
+++ b/src/libsystemd/sd-bus/bus-slot.c
@@ -75,7 +75,7 @@ void bus_slot_disconnect(sd_bus_slot *slot) {
case BUS_REPLY_CALLBACK:
if (slot->reply_callback.cookie != 0)
- hashmap_remove(slot->bus->reply_callbacks, &slot->reply_callback.cookie);
+ ordered_hashmap_remove(slot->bus->reply_callbacks, &slot->reply_callback.cookie);
if (slot->reply_callback.timeout != 0)
prioq_remove(slot->bus->reply_callbacks_prioq, &slot->reply_callback, &slot->reply_callback.prioq_idx);
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index e677a88bac..c17b1a0a0e 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -139,7 +139,7 @@ static void bus_free(sd_bus *b) {
bus_reset_queues(b);
- hashmap_free_free(b->reply_callbacks);
+ ordered_hashmap_free_free(b->reply_callbacks);
prioq_free(b->reply_callbacks_prioq);
assert(b->match_callbacks.type == BUS_MATCH_ROOT);
@@ -1759,7 +1759,7 @@ _public_ int sd_bus_call_async(
if (!BUS_IS_OPEN(bus->state))
return -ENOTCONN;
- r = hashmap_ensure_allocated(&bus->reply_callbacks, &uint64_hash_ops);
+ r = ordered_hashmap_ensure_allocated(&bus->reply_callbacks, &uint64_hash_ops);
if (r < 0)
return r;
@@ -1782,7 +1782,7 @@ _public_ int sd_bus_call_async(
s->reply_callback.callback = callback;
s->reply_callback.cookie = BUS_MESSAGE_COOKIE(m);
- r = hashmap_put(bus->reply_callbacks, &s->reply_callback.cookie, &s->reply_callback);
+ r = ordered_hashmap_put(bus->reply_callbacks, &s->reply_callback.cookie, &s->reply_callback);
if (r < 0) {
s->reply_callback.cookie = 0;
return r;
@@ -2096,7 +2096,7 @@ static int process_timeout(sd_bus *bus) {
assert_se(prioq_pop(bus->reply_callbacks_prioq) == c);
c->timeout = 0;
- hashmap_remove(bus->reply_callbacks, &c->cookie);
+ ordered_hashmap_remove(bus->reply_callbacks, &c->cookie);
c->cookie = 0;
slot = container_of(c, sd_bus_slot, reply_callback);
@@ -2165,7 +2165,7 @@ static int process_reply(sd_bus *bus, sd_bus_message *m) {
if (m->destination && bus->unique_name && !streq_ptr(m->destination, bus->unique_name))
return 0;
- c = hashmap_remove(bus->reply_callbacks, &m->reply_cookie);
+ c = ordered_hashmap_remove(bus->reply_callbacks, &m->reply_cookie);
if (!c)
return 0;
@@ -2499,7 +2499,7 @@ static int process_closing(sd_bus *bus, sd_bus_message **ret) {
assert(bus);
assert(bus->state == BUS_CLOSING);
- c = hashmap_first(bus->reply_callbacks);
+ c = ordered_hashmap_first(bus->reply_callbacks);
if (c) {
_cleanup_bus_error_free_ sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
sd_bus_slot *slot;
@@ -2522,7 +2522,7 @@ static int process_closing(sd_bus *bus, sd_bus_message **ret) {
c->timeout = 0;
}
- hashmap_remove(bus->reply_callbacks, &c->cookie);
+ ordered_hashmap_remove(bus->reply_callbacks, &c->cookie);
c->cookie = 0;
slot = container_of(c, sd_bus_slot, reply_callback);