summaryrefslogtreecommitdiff
path: root/src/libsystemd
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2014-12-11 10:44:41 +0100
committerDavid Herrmann <dh.herrmann@gmail.com>2014-12-11 10:44:41 +0100
commitbecb1a6e9deabad529c8bc1c90eb7d947505695b (patch)
treea4a195939a32ab4de7e05d49b415f48a218938c4 /src/libsystemd
parent1f140dd8b048c5f5599a886b8c4d20f3f1065774 (diff)
bus: fix memfd-cache regarding memfd offsets
We must restore part->mmap_begin when poping memfds from the memfd-cache. We rely on the memfds to be unsealed, so we can be sure that we own the whole FD. Therefore, simply set part->mmap_begin to the same as part->data. This fixes test-bus-kernel-benchmark.
Diffstat (limited to 'src/libsystemd')
-rw-r--r--src/libsystemd/sd-bus/bus-message.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index 06d8d770fd..0803999e07 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -65,9 +65,11 @@ static void message_free_part(sd_bus_message *m, struct bus_body_part *part) {
/* If we can reuse the memfd, try that. For that it
* can't be sealed yet. */
- if (!part->sealed)
+ if (!part->sealed) {
+ assert(part->memfd_offset == 0);
+ assert(part->data == part->mmap_begin);
bus_kernel_push_memfd(m->bus, part->memfd, part->data, part->mapped, part->allocated);
- else {
+ } else {
if (part->mapped > 0)
assert_se(munmap(part->mmap_begin, part->mapped) == 0);
@@ -1103,8 +1105,10 @@ static int part_make_space(
if (m->poisoned)
return -ENOMEM;
- if (!part->data && part->memfd < 0)
+ if (!part->data && part->memfd < 0) {
part->memfd = bus_kernel_pop_memfd(m->bus, &part->data, &part->mapped, &part->allocated);
+ part->mmap_begin = part->data;
+ }
if (part->memfd >= 0) {