[systemd-commits] 7 commits - src/core src/dbus1-generator src/libsystemd-bus src/systemctl units/systemd-bus-proxyd.socket
Lennart Poettering
lennart at kemper.freedesktop.org
Mon Dec 16 12:11:13 PST 2013
src/core/execute.c | 4 ++
src/core/service.c | 3 --
src/dbus1-generator/dbus1-generator.c | 8 +++++
src/libsystemd-bus/bus-internal.h | 4 ++
src/libsystemd-bus/bus-message.c | 19 +++++--------
src/libsystemd-bus/bus-message.h | 3 +-
src/libsystemd-bus/sd-bus.c | 47 ++++++++--------------------------
src/systemctl/systemctl.c | 9 +++---
units/systemd-bus-proxyd.socket | 1
9 files changed, 42 insertions(+), 56 deletions(-)
New commits:
commit 010b2b8d7a694e1e404e35db90e938f6a476bf2f
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Dec 16 21:06:34 2013 +0100
bus: also mask dbus.service in generator if kdbus is found
diff --git a/src/dbus1-generator/dbus1-generator.c b/src/dbus1-generator/dbus1-generator.c
index b0e49bc..d7ecd7f 100644
--- a/src/dbus1-generator/dbus1-generator.c
+++ b/src/dbus1-generator/dbus1-generator.c
@@ -276,6 +276,12 @@ static int link_compatibility(const char *units) {
return -errno;
}
+ t = strappenda(arg_dest, "/" SPECIAL_DBUS_SERVICE);
+ if (symlink("/dev/null", t) < 0) {
+ log_error("Failed to mask %s: %m", t);
+ return -errno;
+ }
+
return 0;
}
commit 77e96a62476b8df284e19a016ad55e6e3e721fb2
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Dec 16 21:02:55 2013 +0100
units: properly make bus proxy socket of type Accept=yes
diff --git a/units/systemd-bus-proxyd.socket b/units/systemd-bus-proxyd.socket
index e955dce..406e15b 100644
--- a/units/systemd-bus-proxyd.socket
+++ b/units/systemd-bus-proxyd.socket
@@ -10,3 +10,4 @@ Description=Legacy D-Bus Protocol Compatibility Socket
[Socket]
ListenStream=/run/dbus/system_bus_socket
+Accept=yes
commit 999b600390a2dff43d3367119ad594b7c40ed50d
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Dec 16 20:53:55 2013 +0100
systemctl: properly initialize and free sd_bus_error in "systemctl cat"
We need to properly initialize all error structs before use and free
them after use.
Also, there's no point in flushing stdout if we output a \n anyway...
diff --git a/src/core/service.c b/src/core/service.c
index 3b3f956..67cf630 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -1254,8 +1254,7 @@ static int service_load(Unit *u) {
s->notify_access = NOTIFY_MAIN;
if (s->type == SERVICE_DBUS || s->bus_name) {
- r = unit_add_two_dependencies_by_name(u, UNIT_AFTER, UNIT_REQUIRES,
- SPECIAL_DBUS_SOCKET, NULL, true);
+ r = unit_add_two_dependencies_by_name(u, UNIT_AFTER, UNIT_REQUIRES, SPECIAL_DBUS_SOCKET, NULL, true);
if (r < 0)
return r;
}
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 9a76349..3e6a688 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -3743,20 +3743,19 @@ static int show_all(
}
static int cat(sd_bus *bus, char **args) {
+ _cleanup_free_ char *unit = NULL, *n = NULL;
int r = 0;
char **name;
- _cleanup_free_ char *unit = NULL, *n = NULL;
-
assert(bus);
assert(args);
pager_open_if_enabled();
STRV_FOREACH(name, args+1) {
- _cleanup_free_ char *fragment_path = NULL;
+ _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_strv_free_ char **dropin_paths = NULL;
- sd_bus_error error;
+ _cleanup_free_ char *fragment_path = NULL;
char **path;
n = unit_name_mangle(*name);
@@ -3800,6 +3799,7 @@ static int cat(sd_bus *bus, char **args) {
if (!isempty(fragment_path)) {
fprintf(stdout, "# %s\n", fragment_path);
fflush(stdout);
+
r = sendfile_full(STDOUT_FILENO, fragment_path);
if (r < 0) {
log_warning("Failed to cat %s: %s", fragment_path, strerror(-r));
@@ -3812,6 +3812,7 @@ static int cat(sd_bus *bus, char **args) {
isempty(fragment_path) && path == dropin_paths ? "" : "\n",
*path);
fflush(stdout);
+
r = sendfile_full(STDOUT_FILENO, *path);
if (r < 0) {
log_warning("Failed to cat %s: %s", *path, strerror(-r));
commit 1c5f57c5a73a90513f1f9c1f534923323b61f68f
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Dec 16 20:39:44 2013 +0100
bus: fix symlink to bus proxy socket
diff --git a/src/dbus1-generator/dbus1-generator.c b/src/dbus1-generator/dbus1-generator.c
index e86fc6e..b0e49bc 100644
--- a/src/dbus1-generator/dbus1-generator.c
+++ b/src/dbus1-generator/dbus1-generator.c
@@ -267,7 +267,7 @@ static int link_busnames_target(const char *units) {
static int link_compatibility(const char *units) {
const char *f, *t;
- f = strappenda(units, "/systemd-socket-proxy.socket");
+ f = strappenda(units, "/systemd-bus-proxyd.socket");
t = strappenda(arg_dest, "/" SPECIAL_DBUS_SOCKET);
mkdir_parents_label(t, 0755);
commit 821e0756c62d705252ab13d24af941578c0b9642
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Dec 16 20:32:37 2013 +0100
bus: use GREEDY_REALLOC() when allocating message queues
diff --git a/src/libsystemd-bus/bus-internal.h b/src/libsystemd-bus/bus-internal.h
index a599e5a..7af8c1e 100644
--- a/src/libsystemd-bus/bus-internal.h
+++ b/src/libsystemd-bus/bus-internal.h
@@ -168,11 +168,13 @@ struct sd_bus {
size_t rbuffer_size;
sd_bus_message **rqueue;
- unsigned rqueue_size, rqueue_allocated;
+ unsigned rqueue_size;
+ size_t rqueue_allocated;
sd_bus_message **wqueue;
unsigned wqueue_size;
size_t windex;
+ size_t wqueue_allocated;
uint64_t serial;
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 4eaceef..76a27ec 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -118,6 +118,7 @@ static void bus_reset_queues(sd_bus *b) {
free(b->wqueue);
b->rqueue = b->wqueue = NULL;
+ b->rqueue_allocated = b->wqueue_allocated = 0;
b->rqueue_size = b->wqueue_size = 0;
}
@@ -195,8 +196,7 @@ _public_ int sd_bus_new(sd_bus **ret) {
/* We guarantee that wqueue always has space for at least one
* entry */
- r->wqueue = new(sd_bus_message*, 1);
- if (!r->wqueue) {
+ if (!GREEDY_REALLOC(r->wqueue, r->wqueue_allocated, 1)) {
free(r);
return -ENOMEM;
}
@@ -397,7 +397,7 @@ int bus_start_running(sd_bus *bus) {
}
static int parse_address_key(const char **p, const char *key, char **value) {
- size_t l, n = 0;
+ size_t l, n = 0, allocated = 0;
const char *a;
char *r = NULL;
@@ -421,7 +421,7 @@ static int parse_address_key(const char **p, const char *key, char **value) {
a = *p;
while (*a != ';' && *a != ',' && *a != 0) {
- char c, *t;
+ char c;
if (*a == '%') {
int x, y;
@@ -445,13 +445,9 @@ static int parse_address_key(const char **p, const char *key, char **value) {
a++;
}
- t = realloc(r, n + 2);
- if (!t) {
- free(r);
+ if (!GREEDY_REALLOC(r, allocated, n + 2))
return -ENOMEM;
- }
- r = t;
r[n++] = c;
}
@@ -614,6 +610,7 @@ static int parse_exec_address(sd_bus *b, const char **p, char **guid) {
char *path = NULL;
unsigned n_argv = 0, j;
char **argv = NULL;
+ size_t allocated = 0;
int r;
assert(b);
@@ -647,17 +644,11 @@ static int parse_exec_address(sd_bus *b, const char **p, char **guid) {
(*p) ++;
if (ul >= n_argv) {
- char **x;
-
- x = realloc(argv, sizeof(char*) * (ul + 2));
- if (!x) {
+ if (!GREEDY_REALLOC0(argv, allocated, ul + 2)) {
r = -ENOMEM;
goto fail;
}
- memset(x + n_argv, 0, sizeof(char*) * (ul - n_argv + 2));
-
- argv = x;
n_argv = ul + 1;
}
@@ -1422,24 +1413,14 @@ static int bus_read_message(sd_bus *bus) {
}
int bus_rqueue_make_room(sd_bus *bus) {
- sd_bus_message **q;
- unsigned x;
-
- x = bus->rqueue_size + 1;
-
- if (bus->rqueue_allocated >= x)
- return 0;
+ assert(bus);
- if (x > BUS_RQUEUE_MAX)
+ if (bus->rqueue_size >= BUS_RQUEUE_MAX)
return -ENOBUFS;
- q = realloc(bus->rqueue, x * sizeof(sd_bus_message*));
- if (!q)
+ if (!GREEDY_REALLOC(bus->rqueue, bus->rqueue_allocated, bus->rqueue_size + 1))
return -ENOMEM;
- bus->rqueue = q;
- bus->rqueue_allocated = x;
-
return 0;
}
@@ -1521,19 +1502,15 @@ _public_ int sd_bus_send(sd_bus *bus, sd_bus_message *m, uint64_t *serial) {
bus->windex = idx;
}
} else {
- sd_bus_message **q;
-
/* Just append it to the queue. */
if (bus->wqueue_size >= BUS_WQUEUE_MAX)
return -ENOBUFS;
- q = realloc(bus->wqueue, sizeof(sd_bus_message*) * (bus->wqueue_size + 1));
- if (!q)
+ if (!GREEDY_REALLOC(bus->wqueue, bus->wqueue_allocated, bus->wqueue_size + 1))
return -ENOMEM;
- bus->wqueue = q;
- q[bus->wqueue_size ++] = sd_bus_message_ref(m);
+ bus->wqueue[bus->wqueue_size ++] = sd_bus_message_ref(m);
}
if (serial)
commit 306f07be2fe2b4ccf6c9575ef8c980661df2aba8
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Dec 16 20:00:25 2013 +0100
bus: let's use GREEDY_REALLOC() when allocating space for containers
diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c
index 8d449c5..3f70f6f 100644
--- a/src/libsystemd-bus/bus-message.c
+++ b/src/libsystemd-bus/bus-message.c
@@ -113,7 +113,7 @@ static void message_reset_containers(sd_bus_message *m) {
free(m->containers);
m->containers = NULL;
- m->n_containers = 0;
+ m->n_containers = m->containers_allocated = 0;
m->root_container.index = 0;
}
@@ -1109,7 +1109,7 @@ static int message_add_offset(sd_bus_message *m, size_t offset) {
if (!c->need_offsets)
return 0;
- if (!GREEDY_REALLOC(c->offsets, c->n_offsets_allocated, c->n_offsets + 1))
+ if (!GREEDY_REALLOC(c->offsets, c->offsets_allocated, c->n_offsets + 1))
return -ENOMEM;
c->offsets[c->n_offsets++] = offset;
@@ -1843,14 +1843,11 @@ _public_ int sd_bus_message_open_container(
assert_return(!m->poisoned, -ESTALE);
/* Make sure we have space for one more container */
- w = realloc(m->containers, sizeof(struct bus_container) * (m->n_containers + 1));
- if (!w) {
+ if (!GREEDY_REALLOC(m->containers, m->containers_allocated, m->n_containers + 1)) {
m->poisoned = true;
return -ENOMEM;
}
- m->containers = w;
-
c = message_get_container(m);
signature = strdup(contents);
@@ -1881,14 +1878,14 @@ _public_ int sd_bus_message_open_container(
}
/* OK, let's fill it in */
- w += m->n_containers++;
+ w = m->containers + m->n_containers++;
w->enclosing = type;
w->signature = signature;
w->index = 0;
w->array_size = array_size;
w->before = before;
w->begin = begin;
- w->n_offsets = w->n_offsets_allocated = 0;
+ w->n_offsets = w->offsets_allocated = 0;
w->offsets = NULL;
w->need_offsets = need_offsets;
@@ -3854,10 +3851,8 @@ _public_ int sd_bus_message_enter_container(sd_bus_message *m,
if (m->n_containers >= BUS_CONTAINER_DEPTH)
return -EBADMSG;
- w = realloc(m->containers, sizeof(struct bus_container) * (m->n_containers + 1));
- if (!w)
+ if (!GREEDY_REALLOC(m->containers, m->containers_allocated, m->n_containers + 1))
return -ENOMEM;
- m->containers = w;
if (message_end_of_signature(m))
return -ENXIO;
@@ -3892,7 +3887,7 @@ _public_ int sd_bus_message_enter_container(sd_bus_message *m,
}
/* OK, let's fill it in */
- w += m->n_containers++;
+ w = m->containers + m->n_containers++;
w->enclosing = type;
w->signature = signature;
w->index = 0;
diff --git a/src/libsystemd-bus/bus-message.h b/src/libsystemd-bus/bus-message.h
index b9cd4c8..9ef92cf 100644
--- a/src/libsystemd-bus/bus-message.h
+++ b/src/libsystemd-bus/bus-message.h
@@ -46,7 +46,7 @@ struct bus_container {
uint32_t *array_size;
/* gvariant: list of offsets to end of children if this is struct/dict entry/array */
- size_t *offsets, n_offsets, n_offsets_allocated, offset_index;
+ size_t *offsets, n_offsets, offsets_allocated, offset_index;
size_t item_size;
};
@@ -115,6 +115,7 @@ struct sd_bus_message {
struct bus_container root_container, *containers;
unsigned n_containers;
+ size_t containers_allocated;
struct iovec *iovec;
struct iovec iovec_fixed[2];
commit 531dca789ea6b4c269ca2646515b42962f83d64a
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Dec 16 20:00:09 2013 +0100
execute: also set SO_SNDBUF when spawning a service with stdout/stderr connected to journald
diff --git a/src/core/execute.c b/src/core/execute.c
index 55b8bb5..5abc69d 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -75,6 +75,8 @@
/* This assumes there is a 'tty' group */
#define TTY_MODE 0620
+#define SNDBUF_SIZE (8*1024*1024)
+
static int shift_fds(int fds[], unsigned n_fds) {
int start, restart_from;
@@ -221,6 +223,8 @@ static int connect_logger_as(const ExecContext *context, ExecOutput output, cons
return -errno;
}
+ fd_inc_sndbuf(fd, SNDBUF_SIZE);
+
dprintf(fd,
"%s\n"
"%s\n"
More information about the systemd-commits
mailing list