chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bus: calculate iovec for messages only when we need it
[elogind.git]
/
src
/
libsystemd-bus
/
sd-bus.c
diff --git
a/src/libsystemd-bus/sd-bus.c
b/src/libsystemd-bus/sd-bus.c
index 6f8d444a660e1b0a401d550a96a2c5cae59220f8..89172e6369c3dd5ea8d69fbdfc366c4028faf2c0 100644
(file)
--- a/
src/libsystemd-bus/sd-bus.c
+++ b/
src/libsystemd-bus/sd-bus.c
@@
-436,8
+436,11
@@
static int parse_unix_address(sd_bus *b, const char **p, char **guid) {
static int parse_tcp_address(sd_bus *b, const char **p, char **guid) {
_cleanup_free_ char *host = NULL, *port = NULL, *family = NULL;
static int parse_tcp_address(sd_bus *b, const char **p, char **guid) {
_cleanup_free_ char *host = NULL, *port = NULL, *family = NULL;
- struct addrinfo hints, *result;
int r;
int r;
+ struct addrinfo *result, hints = {
+ .ai_socktype = SOCK_STREAM,
+ .ai_flags = AI_ADDRCONFIG,
+ };
assert(b);
assert(p);
assert(b);
assert(p);
@@
-475,10
+478,6
@@
static int parse_tcp_address(sd_bus *b, const char **p, char **guid) {
if (!host || !port)
return -EINVAL;
if (!host || !port)
return -EINVAL;
- zero(hints);
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags = AI_ADDRCONFIG;
-
if (family) {
if (streq(family, "ipv4"))
hints.ai_family = AF_INET;
if (family) {
if (streq(family, "ipv4"))
hints.ai_family = AF_INET;
@@
-966,7
+965,7
@@
static int dispatch_wqueue(sd_bus *bus) {
} else if (r == 0)
/* Didn't do anything this time */
return ret;
} else if (r == 0)
/* Didn't do anything this time */
return ret;
- else if (bus->windex >= bus
->wqueue[0]->size
) {
+ else if (bus->windex >= bus
_message_size(bus->wqueue[0])
) {
/* Fully written. Let's drop the entry from
* the queue.
*
/* Fully written. Let's drop the entry from
* the queue.
*
@@
-1067,7
+1066,7
@@
int sd_bus_send(sd_bus *bus, sd_bus_message *m, uint64_t *serial) {
if (r < 0) {
sd_bus_close(bus);
return r;
if (r < 0) {
sd_bus_close(bus);
return r;
- } else if (idx <
m->size
) {
+ } else if (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
/* 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
@@
-1937,7
+1936,7
@@
int sd_bus_process(sd_bus *bus, sd_bus_message **ret) {
}
static int bus_poll(sd_bus *bus, bool need_more, uint64_t timeout_usec) {
}
static int bus_poll(sd_bus *bus, bool need_more, uint64_t timeout_usec) {
- struct pollfd p[2];
+ struct pollfd p[2]
= {}
;
int r, e, n;
struct timespec ts;
usec_t until, m;
int r, e, n;
struct timespec ts;
usec_t until, m;
@@
-1968,9
+1967,7
@@
static int bus_poll(sd_bus *bus, bool need_more, uint64_t timeout_usec) {
if (timeout_usec != (uint64_t) -1 && (m == (uint64_t) -1 || timeout_usec < m))
m = timeout_usec;
if (timeout_usec != (uint64_t) -1 && (m == (uint64_t) -1 || timeout_usec < m))
m = timeout_usec;
- zero(p);
p[0].fd = bus->input_fd;
p[0].fd = bus->input_fd;
-
if (bus->output_fd == bus->input_fd) {
p[0].events = e;
n = 1;
if (bus->output_fd == bus->input_fd) {
p[0].events = e;
n = 1;