mirror of
https://github.com/systemd/systemd.git
synced 2024-11-08 11:27:32 +03:00
Merge pull request #804 from dvdhrm/proxy-directed2
bus-proxy: make NameAcquired/Lost directed (v2)
This commit is contained in:
commit
e87cedf350
@ -653,6 +653,10 @@ static int process_hello(Proxy *p, sd_bus_message *m) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to append sender to NameAcquired message: %m");
|
return log_error_errno(r, "Failed to append sender to NameAcquired message: %m");
|
||||||
|
|
||||||
|
r = sd_bus_message_set_destination(n, p->destination_bus->unique_name);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to set destination for NameAcquired message: %m");
|
||||||
|
|
||||||
r = bus_seal_synthetic_message(p->local_bus, n);
|
r = bus_seal_synthetic_message(p->local_bus, n);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to seal NameAcquired message: %m");
|
return log_error_errno(r, "Failed to seal NameAcquired message: %m");
|
||||||
|
@ -214,22 +214,13 @@ int synthesize_name_acquired(Proxy *p, sd_bus *a, sd_bus *b, sd_bus_message *m)
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
r = sd_bus_message_set_destination(n, a->unique_name);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
r = bus_seal_synthetic_message(b, n);
|
r = bus_seal_synthetic_message(b, n);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
/*
|
return sd_bus_send(b, n, NULL);
|
||||||
* Make sure to only forward NameLost/NameAcquired messages if they
|
|
||||||
* match an installed MATCH rule of the local client. We really must
|
|
||||||
* not send messages the client doesn't expect.
|
|
||||||
*/
|
|
||||||
|
|
||||||
r = bus_match_run(b, &b->match_callbacks, n);
|
|
||||||
if (r >= 0 && p->message_matched)
|
|
||||||
r = sd_bus_send(b, n, NULL);
|
|
||||||
|
|
||||||
p->message_matched = false;
|
|
||||||
p->synthetic_matched = false;
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,9 @@ static int test_proxy_acquired(sd_bus_message *m, void *userdata, sd_bus_error *
|
|||||||
|
|
||||||
static void test_proxy_matched(void) {
|
static void test_proxy_matched(void) {
|
||||||
_cleanup_bus_flush_close_unref_ sd_bus *a = NULL;
|
_cleanup_bus_flush_close_unref_ sd_bus *a = NULL;
|
||||||
|
_cleanup_free_ char *matchstr = NULL;
|
||||||
TestProxyMatch match = {};
|
TestProxyMatch match = {};
|
||||||
|
const char *me;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
/* open bus 'a' */
|
/* open bus 'a' */
|
||||||
@ -70,10 +72,17 @@ static void test_proxy_matched(void) {
|
|||||||
r = sd_bus_start(a);
|
r = sd_bus_start(a);
|
||||||
assert_se(r >= 0);
|
assert_se(r >= 0);
|
||||||
|
|
||||||
r = sd_bus_add_match(a, NULL,
|
r = sd_bus_get_unique_name(a, &me);
|
||||||
"type='signal',"
|
assert_se(r >= 0);
|
||||||
"member='NameAcquired'",
|
|
||||||
test_proxy_acquired, &match);
|
matchstr = strjoin("type='signal',"
|
||||||
|
"member='NameAcquired',"
|
||||||
|
"destination='",
|
||||||
|
me,
|
||||||
|
"'",
|
||||||
|
NULL);
|
||||||
|
assert_se(matchstr);
|
||||||
|
r = sd_bus_add_match(a, NULL, matchstr, test_proxy_acquired, &match);
|
||||||
assert_se(r >= 0);
|
assert_se(r >= 0);
|
||||||
|
|
||||||
r = sd_bus_get_unique_name(a, &match.sender);
|
r = sd_bus_get_unique_name(a, &match.sender);
|
||||||
|
Loading…
Reference in New Issue
Block a user