mirror of
https://github.com/systemd/systemd.git
synced 2025-02-06 01:57:47 +03:00
bus: add sd_bus_get_current() bus call to determine message that is currently being dispatched
This commit is contained in:
parent
4e724d9c5a
commit
affff0b6f2
@ -247,6 +247,8 @@ struct sd_bus {
|
||||
sd_event_source *time_event_source;
|
||||
sd_event_source *quit_event_source;
|
||||
sd_event *event;
|
||||
|
||||
sd_bus_message *current;
|
||||
};
|
||||
|
||||
#define BUS_DEFAULT_TIMEOUT ((usec_t) (25 * USEC_PER_SEC))
|
||||
|
@ -1931,6 +1931,7 @@ static int process_message(sd_bus *bus, sd_bus_message *m) {
|
||||
assert(bus);
|
||||
assert(m);
|
||||
|
||||
bus->current = m;
|
||||
bus->iteration_counter++;
|
||||
|
||||
log_debug("Got message sender=%s object=%s interface=%s member=%s",
|
||||
@ -1941,25 +1942,29 @@ static int process_message(sd_bus *bus, sd_bus_message *m) {
|
||||
|
||||
r = process_hello(bus, m);
|
||||
if (r != 0)
|
||||
return r;
|
||||
goto finish;
|
||||
|
||||
r = process_reply(bus, m);
|
||||
if (r != 0)
|
||||
return r;
|
||||
goto finish;
|
||||
|
||||
r = process_filter(bus, m);
|
||||
if (r != 0)
|
||||
return r;
|
||||
goto finish;
|
||||
|
||||
r = process_match(bus, m);
|
||||
if (r != 0)
|
||||
return r;
|
||||
goto finish;
|
||||
|
||||
r = process_builtin(bus, m);
|
||||
if (r != 0)
|
||||
return r;
|
||||
goto finish;
|
||||
|
||||
return bus_process_object(bus, m);
|
||||
r = bus_process_object(bus, m);
|
||||
|
||||
finish:
|
||||
bus->current = NULL;
|
||||
return r;
|
||||
}
|
||||
|
||||
static int process_running(sd_bus *bus, sd_bus_message **ret) {
|
||||
@ -2422,3 +2427,9 @@ int sd_bus_detach_event(sd_bus *bus) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sd_bus_message* sd_bus_get_current(sd_bus *bus) {
|
||||
assert_return(bus, NULL);
|
||||
|
||||
return bus->current;
|
||||
}
|
||||
|
@ -101,6 +101,8 @@ int sd_bus_process(sd_bus *bus, sd_bus_message **r);
|
||||
int sd_bus_wait(sd_bus *bus, uint64_t timeout_usec);
|
||||
int sd_bus_flush(sd_bus *bus);
|
||||
|
||||
sd_bus_message* sd_bus_get_current(sd_bus *bus);
|
||||
|
||||
int sd_bus_attach_event(sd_bus *bus, sd_event *e, int priority);
|
||||
int sd_bus_detach_event(sd_bus *bus);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user