[PATCH] afsocket: Fix unix-dgram initialisation
When initializing an unix-dgram socket, set self->fd to the acquired socket FD, so that fds inherited from systemd actually get used and polled on. Signed-off-by: Gergely Nagy <algernon@balabit.hu> --- modules/afsocket/afsocket.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/modules/afsocket/afsocket.c b/modules/afsocket/afsocket.c index 5b192f4..c1bee5c 100644 --- a/modules/afsocket/afsocket.c +++ b/modules/afsocket/afsocket.c @@ -679,7 +679,7 @@ afsocket_sd_init(LogPipe *s) if (sock == -1 && !afsocket_open_socket(self->bind_addr, !!(self->flags & AFSOCKET_STREAM), &sock)) return self->super.super.optional; } - self->fd = -1; + self->fd = sock; if (!self->setup_socket(self, sock)) { -- 1.7.9.1
On Fri, 2012-04-20 at 18:06 +0200, Gergely Nagy wrote:
When initializing an unix-dgram socket, set self->fd to the acquired socket FD, so that fds inherited from systemd actually get used and polled on.
Signed-off-by: Gergely Nagy <algernon@balabit.hu> --- modules/afsocket/afsocket.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/modules/afsocket/afsocket.c b/modules/afsocket/afsocket.c index 5b192f4..c1bee5c 100644 --- a/modules/afsocket/afsocket.c +++ b/modules/afsocket/afsocket.c @@ -679,7 +679,7 @@ afsocket_sd_init(LogPipe *s) if (sock == -1 && !afsocket_open_socket(self->bind_addr, !!(self->flags & AFSOCKET_STREAM), &sock)) return self->super.super.optional; } - self->fd = -1; + self->fd = sock;
if (!self->setup_socket(self, sock)) {
hmm... this is exactly the case where a variable with a better name would have prevented some effort. self->fd is the _listener_ fd which a SOCK_DGRAM style socket lacks. That's why it is set to -1 The dgram socket is processed as if it was a single connection, a couple of lines below this hunk, there's a call to afsocket_sd_process_connection(), which should initialize an AFSocketSourceConnection object, which in turn should start polling that fd. What was your intent here? -- Bazsi
Balazs Scheidler <bazsi@balabit.hu> writes:
diff --git a/modules/afsocket/afsocket.c b/modules/afsocket/afsocket.c index 5b192f4..c1bee5c 100644 --- a/modules/afsocket/afsocket.c +++ b/modules/afsocket/afsocket.c @@ -679,7 +679,7 @@ afsocket_sd_init(LogPipe *s) if (sock == -1 && !afsocket_open_socket(self->bind_addr, !!(self->flags & AFSOCKET_STREAM), &sock)) return self->super.super.optional; } - self->fd = -1; + self->fd = sock;
if (!self->setup_socket(self, sock)) {
hmm... this is exactly the case where a variable with a better name would have prevented some effort.
self->fd is the _listener_ fd which a SOCK_DGRAM style socket lacks. That's why it is set to -1
The dgram socket is processed as if it was a single connection, a couple of lines below this hunk, there's a call to afsocket_sd_process_connection(), which should initialize an AFSocketSourceConnection object, which in turn should start polling that fd.
What was your intent here?
To get a systemd-managed /run/systemd/journal/syslog thing working. I'm not entirely sure why, but without this patch, the thing was never polled. I'll try to figure out what else went wrong, as time permits. -- |8]
Balazs Scheidler <bazsi@balabit.hu> writes:
hmm... this is exactly the case where a variable with a better name would have prevented some effort.
self->fd is the _listener_ fd which a SOCK_DGRAM style socket lacks. That's why it is set to -1
The dgram socket is processed as if it was a single connection, a couple of lines below this hunk, there's a call to afsocket_sd_process_connection(), which should initialize an AFSocketSourceConnection object, which in turn should start polling that fd.
What was your intent here?
Turns out, whatever I saw, must have been a ghost: I can't reproduce the problem anymore, so please ignore this patch. -- |8]
participants (2)
-
Balazs Scheidler
-
Gergely Nagy