[systemd-devel] Is sd_journal_send non-blocking?
Lennart Poettering
lennart at poettering.net
Mon Feb 6 11:36:01 UTC 2017
On Mon, 06.02.17 11:12, Florian Weimer (fweimer at redhat.com) wrote:
> The manual page I've got does not say it is, but the implementation does not
> wait for acknowledgment from the journal. The implementation does not block
> explicitly, but I think the sendmsg call can block until the receiver queue
> is empty.
>
> The background for this question is that we have a feature request for a
> non-blocking logging interface. I wonder if the journal fits this
> requirement.
>
> I assume that with “non-blocking”, the feature request submitter means that
> the function does not block indefinitely, say due to a service process
> outage. Memory allocations can take a fairly long time as well (due to
> paging), but I think that doesn't count here.
The socket we use is blocking, but we try to increase the socket
buffer to 8M, to move the point where we start to block out late. But
that only works with sufficient privileges.
So yes, we are always blocking, we don't throw data away.
I'd be willing to take a patch however, that adds a call
sd_journal_set_block_timeout() or so, that takes a time value we pass
to SO_SNDTIMEO for the logging socket. This would permit clients to
precisely control how long they want us to wait before we give up. And
in the case where a zero timeout is set we'd instead set O_NONBLOCK,
thus making logging entirely non-blocking.
But of course, you can't have it both. Pick one of "don't lose
messages" and "never block". Right now we always opt for the former,
with such a function call you could give that up and opt for the
latter.
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list