X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flibsystemd%2Fsd-bus%2Fsd-bus.c;h=125b302c95455f6a7b22623827e9dd63da62969d;hb=997eadb5534cbd3d1de3d93f6489a3b4d03405e1;hp=f87c31651b74c34382182b8875d8f23deddbcc5d;hpb=de33fc625725d199629ed074d6278504deb23deb;p=elogind.git diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index f87c31651..125b302c9 100644 --- a/src/libsystemd/sd-bus/sd-bus.c +++ b/src/libsystemd/sd-bus/sd-bus.c @@ -952,7 +952,7 @@ static int bus_parse_next_address(sd_bus *b) { break; } else if (startswith(a, "x-machine-unix:")) { - a += 17; + a += 15; r = parse_container_unix_address(b, &a, &guid); if (r < 0) return r; @@ -960,7 +960,7 @@ static int bus_parse_next_address(sd_bus *b) { break; } else if (startswith(a, "x-machine-kernel:")) { - a += 19; + a += 17; r = parse_container_kernel_address(b, &a, &guid); if (r < 0) return r; @@ -1528,6 +1528,16 @@ int bus_seal_synthetic_message(sd_bus *b, sd_bus_message *m) { assert(b); assert(m); + /* Fake some timestamps, if they were requested, and not + * already initialized */ + if (b->attach_flags & KDBUS_ATTACH_TIMESTAMP) { + if (m->realtime <= 0) + m->realtime = now(CLOCK_REALTIME); + + if (m->monotonic <= 0) + m->monotonic = now(CLOCK_MONOTONIC); + } + /* The bus specification says the serial number cannot be 0, * hence let's fill something in for synthetic messages. Since * synthetic messages might have a fake sender and we don't @@ -1535,7 +1545,6 @@ int bus_seal_synthetic_message(sd_bus *b, sd_bus_message *m) { * pick a fixed, artificial one. We use (uint32_t) -1 rather * than (uint64_t) -1 since dbus1 only had 32bit identifiers, * even though kdbus can do 64bit. */ - return bus_message_seal(m, 0xFFFFFFFFULL, 0); } @@ -1695,8 +1704,8 @@ static int bus_send_internal(sd_bus *bus, sd_bus_message *_m, uint64_t *cookie, /* If this is a reply and no reply was requested, then let's * suppress this, if we can */ - if (m->dont_send && !cookie) - return 1; + if (m->dont_send) + goto finish; if ((bus->state == BUS_RUNNING || bus->state == BUS_HELLO) && bus->wqueue_size <= 0) { size_t idx = 0; @@ -1709,7 +1718,9 @@ static int bus_send_internal(sd_bus *bus, sd_bus_message *_m, uint64_t *cookie, } return r; - } else if (!bus->is_kernel && idx < BUS_MESSAGE_SIZE(m)) { + } + + if (!bus->is_kernel && idx < BUS_MESSAGE_SIZE(m)) { /* Wasn't fully written. So let's remember how * much was written. Note that the first entry * of the wqueue array is always allocated so @@ -1719,6 +1730,7 @@ static int bus_send_internal(sd_bus *bus, sd_bus_message *_m, uint64_t *cookie, bus->wqueue_size = 1; bus->windex = idx; } + } else { /* Just append it to the queue. */ @@ -1731,6 +1743,7 @@ static int bus_send_internal(sd_bus *bus, sd_bus_message *_m, uint64_t *cookie, bus->wqueue[bus->wqueue_size ++] = sd_bus_message_ref(m); } +finish: if (cookie) *cookie = BUS_MESSAGE_COOKIE(m); @@ -2140,8 +2153,6 @@ static int process_timeout(sd_bus *bus) { if (r < 0) return r; - m->sender = "org.freedesktop.DBus"; - r = bus_seal_synthetic_message(bus, m); if (r < 0) return r; @@ -2239,6 +2250,11 @@ static int process_reply(sd_bus *bus, sd_bus_message *m) { if (r < 0) return r; + /* Copy over original timestamp */ + synthetic_reply->realtime = m->realtime; + synthetic_reply->monotonic = m->monotonic; + synthetic_reply->seqnum = m->seqnum; + r = bus_seal_synthetic_message(bus, synthetic_reply); if (r < 0) return r; @@ -2544,15 +2560,6 @@ null_message: return r; } -static void bus_message_set_sender_local(sd_bus *bus, sd_bus_message *m) { - assert(bus); - assert(m); - - m->sender = m->creds.unique_name = (char*) "org.freedesktop.DBus.Local"; - m->creds.well_known_names_local = true; - m->creds.mask |= (SD_BUS_CREDS_UNIQUE_NAME|SD_BUS_CREDS_WELL_KNOWN_NAMES) & bus->creds_mask; -} - static int process_closing(sd_bus *bus, sd_bus_message **ret) { _cleanup_bus_message_unref_ sd_bus_message *m = NULL; struct reply_callback *c;