1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 19:21:53 +03:00

bus: when we unmarshal an fd it should stay owned by the message object

If the user wants the fd to stay valid he should keep a reference to the
message object or duplicate the fd.

This unifies behaviour of demarshalling data fields and unix fds.
This commit is contained in:
Lennart Poettering 2013-04-10 23:04:20 +02:00
parent 50fb97935d
commit 1ef2af5ae0
2 changed files with 1 additions and 8 deletions

View File

@ -1710,18 +1710,13 @@ int sd_bus_message_read_basic(sd_bus_message *m, char type, void *p) {
break;
case SD_BUS_TYPE_UNIX_FD: {
int copy;
uint32_t j;
j = BUS_MESSAGE_BSWAP32(m, *(uint32_t*) q);
if (j >= m->n_fds)
return -EBADMSG;
copy = fcntl(m->fds[j], F_DUPFD_CLOEXEC, 3);
if (copy < 0)
return -errno;
*(int*) p = copy;
*(int*) p = m->fds[j];
break;
}

View File

@ -230,8 +230,6 @@ static int server(sd_bus *bus) {
goto fail;
}
close_nointr_nofail(fd);
r = sd_bus_reply_method_return(bus, m, NULL);
if (r < 0) {
log_error("Failed to send reply: %s", strerror(-r));