From 5263c249495bc54ddee1c6fabffad3045248446b Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Mon, 9 Nov 2020 20:52:06 +0100 Subject: [PATCH] sd-bus: Remove sd_bus_(attach|detach|get)_event --- src/libsystemd/sd-bus/sd-bus.c | 113 --------------------------------- src/systemd/sd-bus.h | 4 -- 2 files changed, 117 deletions(-) diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index 8a7fb3c..42ac89b 100644 --- a/src/libsystemd/sd-bus/sd-bus.c +++ b/src/libsystemd/sd-bus/sd-bus.c @@ -148,8 +148,6 @@ static sd_bus* bus_free(sd_bus *b) { b->state = BUS_CLOSED; - sd_bus_detach_event(b); - while ((s = b->slots)) { /* At this point only floating slots can still be * around, because the non-floating ones keep a @@ -1517,8 +1515,6 @@ _public_ void sd_bus_close(sd_bus *bus) { bus_set_state(bus, BUS_CLOSED); - sd_bus_detach_event(bus); - /* Drop all queued messages so that they drop references to * the bus object and the bus may be freed */ bus_reset_queues(bus); @@ -3284,21 +3280,6 @@ static int io_callback(sd_event_source *s, int fd, uint32_t revents, void *userd return 1; } -static int time_callback(sd_event_source *s, uint64_t usec, void *userdata) { - sd_bus *bus = userdata; - int r; - - assert(bus); - - r = sd_bus_process(bus, NULL); - if (r < 0) { - log_debug_errno(r, "Processing of bus failed, closing down: %m"); - bus_enter_closing(bus); - } - - return 1; -} - static int prepare_callback(sd_event_source *s, void *userdata) { sd_bus *bus = userdata; int r, e; @@ -3351,19 +3332,6 @@ fail: return 1; } -static int quit_callback(sd_event_source *event, void *userdata) { - sd_bus *bus = userdata; - - assert(event); - - if (bus->close_on_exit) { - sd_bus_flush(bus); - sd_bus_close(bus); - } - - return 1; -} - int bus_attach_io_events(sd_bus *bus) { int r; @@ -3432,87 +3400,6 @@ static void bus_detach_io_events(sd_bus *bus) { } } -_public_ int sd_bus_attach_event(sd_bus *bus, sd_event *event, int priority) { - int r; - - assert_return(bus, -EINVAL); - assert_return(bus = bus_resolve(bus), -ENOPKG); - assert_return(!bus->event, -EBUSY); - - assert(!bus->input_io_event_source); - assert(!bus->output_io_event_source); - assert(!bus->time_event_source); - - if (event) - bus->event = sd_event_ref(event); - else { - r = sd_event_default(&bus->event); - if (r < 0) - return r; - } - - bus->event_priority = priority; - - r = sd_event_add_time(bus->event, &bus->time_event_source, CLOCK_MONOTONIC, 0, 0, time_callback, bus); - if (r < 0) - goto fail; - - r = sd_event_source_set_priority(bus->time_event_source, priority); - if (r < 0) - goto fail; - - r = sd_event_source_set_description(bus->time_event_source, "bus-time"); - if (r < 0) - goto fail; - - r = sd_event_add_exit(bus->event, &bus->quit_event_source, quit_callback, bus); - if (r < 0) - goto fail; - - r = sd_event_source_set_description(bus->quit_event_source, "bus-exit"); - if (r < 0) - goto fail; - - r = bus_attach_io_events(bus); - if (r < 0) - goto fail; - - return 0; - -fail: - sd_bus_detach_event(bus); - return r; -} - -_public_ int sd_bus_detach_event(sd_bus *bus) { - assert_return(bus, -EINVAL); - assert_return(bus = bus_resolve(bus), -ENOPKG); - - if (!bus->event) - return 0; - - bus_detach_io_events(bus); - - if (bus->time_event_source) { - sd_event_source_set_enabled(bus->time_event_source, SD_EVENT_OFF); - bus->time_event_source = sd_event_source_unref(bus->time_event_source); - } - - if (bus->quit_event_source) { - sd_event_source_set_enabled(bus->quit_event_source, SD_EVENT_OFF); - bus->quit_event_source = sd_event_source_unref(bus->quit_event_source); - } - - bus->event = sd_event_unref(bus->event); - return 1; -} - -_public_ sd_event* sd_bus_get_event(sd_bus *bus) { - assert_return(bus, NULL); - - return bus->event; -} - _public_ sd_bus_message* sd_bus_get_current_message(sd_bus *bus) { assert_return(bus, NULL); diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h index 220ddb9..20ce5a5 100644 --- a/src/systemd/sd-bus.h +++ b/src/systemd/sd-bus.h @@ -200,10 +200,6 @@ sd_bus_message* sd_bus_get_current_message(sd_bus *bus); sd_bus_message_handler_t sd_bus_get_current_handler(sd_bus *bus); void* sd_bus_get_current_userdata(sd_bus *bus); -int sd_bus_attach_event(sd_bus *bus, sd_event *e, int priority); -int sd_bus_detach_event(sd_bus *bus); -sd_event *sd_bus_get_event(sd_bus *bus); - int sd_bus_get_n_queued_read(sd_bus *bus, uint64_t *ret); int sd_bus_get_n_queued_write(sd_bus *bus, uint64_t *ret); -- 2.45.2