mirror of
https://github.com/systemd/systemd.git
synced 2025-03-28 02:50:16 +03:00
resolved: move query bus tracking to resolved-bus.c
It's strictly bus-specific, hence let's move this to resolved-bus.c like the rest of the bus specific logic. This is also in preparation for adding an alternative varlink transport, which needs similar functionality, but varlink instead of bus-specific.
This commit is contained in:
parent
c9de4e0f5b
commit
65a01e8242
@ -24,6 +24,39 @@
|
||||
|
||||
BUS_DEFINE_PROPERTY_GET_ENUM(bus_property_get_resolve_support, resolve_support, ResolveSupport);
|
||||
|
||||
static int query_on_bus_track(sd_bus_track *t, void *userdata) {
|
||||
DnsQuery *q = userdata;
|
||||
|
||||
assert(t);
|
||||
assert(q);
|
||||
|
||||
if (!DNS_TRANSACTION_IS_LIVE(q->state))
|
||||
return 0;
|
||||
|
||||
log_debug("Client of active query vanished, aborting query.");
|
||||
dns_query_complete(q, DNS_TRANSACTION_ABORTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dns_query_bus_track(DnsQuery *q, sd_bus_message *m) {
|
||||
int r;
|
||||
|
||||
assert(q);
|
||||
assert(m);
|
||||
|
||||
if (!q->bus_track) {
|
||||
r = sd_bus_track_new(sd_bus_message_get_bus(m), &q->bus_track, query_on_bus_track, q);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
r = sd_bus_track_add_sender(q->bus_track, m);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int reply_query_state(DnsQuery *q) {
|
||||
|
||||
switch (q->state) {
|
||||
@ -1689,7 +1722,7 @@ static int bus_method_reset_server_features(sd_bus_message *message, void *userd
|
||||
return sd_bus_reply_method_return(message, NULL);
|
||||
}
|
||||
|
||||
static int on_bus_track(sd_bus_track *t, void *userdata) {
|
||||
static int dnssd_service_on_bus_track(sd_bus_track *t, void *userdata) {
|
||||
DnssdService *s = userdata;
|
||||
|
||||
assert(t);
|
||||
@ -1862,7 +1895,7 @@ static int bus_method_register_service(sd_bus_message *message, void *userdata,
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_bus_track_new(sd_bus_message_get_bus(message), &bus_track, on_bus_track, service);
|
||||
r = sd_bus_track_new(sd_bus_message_get_bus(message), &bus_track, dnssd_service_on_bus_track, service);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
@ -473,14 +473,13 @@ int dns_query_make_auxiliary(DnsQuery *q, DnsQuery *auxiliary_for) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dns_query_complete(DnsQuery *q, DnsTransactionState state) {
|
||||
void dns_query_complete(DnsQuery *q, DnsTransactionState state) {
|
||||
assert(q);
|
||||
assert(!DNS_TRANSACTION_IS_LIVE(state));
|
||||
assert(DNS_TRANSACTION_IS_LIVE(q->state));
|
||||
|
||||
/* Note that this call might invalidate the query. Callers
|
||||
* should hence not attempt to access the query or transaction
|
||||
* after calling this function. */
|
||||
/* Note that this call might invalidate the query. Callers should hence not attempt to access the
|
||||
* query or transaction after calling this function. */
|
||||
|
||||
q->state = state;
|
||||
|
||||
@ -987,36 +986,6 @@ int dns_query_process_cname(DnsQuery *q) {
|
||||
return DNS_QUERY_RESTARTED; /* We restarted the query for a new cname */
|
||||
}
|
||||
|
||||
static int on_bus_track(sd_bus_track *t, void *userdata) {
|
||||
DnsQuery *q = userdata;
|
||||
|
||||
assert(t);
|
||||
assert(q);
|
||||
|
||||
log_debug("Client of active query vanished, aborting query.");
|
||||
dns_query_complete(q, DNS_TRANSACTION_ABORTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dns_query_bus_track(DnsQuery *q, sd_bus_message *m) {
|
||||
int r;
|
||||
|
||||
assert(q);
|
||||
assert(m);
|
||||
|
||||
if (!q->bus_track) {
|
||||
r = sd_bus_track_new(sd_bus_message_get_bus(m), &q->bus_track, on_bus_track, q);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
r = sd_bus_track_add_sender(q->bus_track, m);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DnsQuestion* dns_query_question_for_protocol(DnsQuery *q, DnsProtocol protocol) {
|
||||
assert(q);
|
||||
|
||||
|
@ -112,7 +112,7 @@ void dns_query_ready(DnsQuery *q);
|
||||
|
||||
int dns_query_process_cname(DnsQuery *q);
|
||||
|
||||
int dns_query_bus_track(DnsQuery *q, sd_bus_message *m);
|
||||
void dns_query_complete(DnsQuery *q, DnsTransactionState state);
|
||||
|
||||
DnsQuestion* dns_query_question_for_protocol(DnsQuery *q, DnsProtocol protocol);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user