From 1a37c9756f0c55917192e1a229977734b1f7ea45 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 17 Oct 2015 16:20:38 +0200 Subject: bus-proxy: don't close local bus fds twice Clear up how we pass fd owner ship to proxy and bus objects. Document that ownership is passed of the fds in question even in case of failing constructors, and that callers should forget about fds pass into the proxy object. The alternative would be to duplicate the fds, but given that fds are a relatively scarce and heavy resource let's better avoid that. Fixes #1591. --- src/bus-proxyd/bus-proxyd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/bus-proxyd/bus-proxyd.c') diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c index 2bc265d9b4..6a4da0f2e2 100644 --- a/src/bus-proxyd/bus-proxyd.c +++ b/src/bus-proxyd/bus-proxyd.c @@ -85,11 +85,11 @@ static void *run_client(void *userdata) { int r; r = proxy_new(&p, c->fd, c->fd, arg_address); + c->fd = -1; + if (r < 0) goto exit; - c->fd = -1; - /* set comm to "p$PIDu$UID" and suffix with '*' if truncated */ r = snprintf(comm, sizeof(comm), "p" PID_FMT "u" UID_FMT, p->local_creds.pid, p->local_creds.uid); if (r >= (ssize_t)sizeof(comm)) -- cgit v1.2.3-54-g00ecf