[systemd-devel] [RFC PATCH 2/2] journal: add async-signal-safe mode for sd_journald_sendv

Lennart Poettering lennart at poettering.net
Mon Jan 27 06:19:14 PST 2014


On Sun, 26.01.14 00:21, Zbigniew Jędrzejewski-Szmek (zbyszek at in.waw.pl) wrote:

>  
> +static int writev_safe(int fd, const struct iovec *w, int j, bool async_signal_safe) {
> +        if (!async_signal_safe)
> +                return writev(fd, w, j);
> +
> +        for (int i = 0; i < j; i++) {
> +                size_t written = 0;
> +
> +                while (written < w[i].iov_len) {
> +                        ssize_t r;
> +
> +                        r = write(fd, w[i].iov_base + written, w[i].iov_len - written);
> +                        if (r < 0 && errno != -EINTR)
> +                                return -errno;
> +
> +                        written += r;
> +                }
> +        }
> +
> +        return 0;
> +}

I don't follow here. What's the rationale for using write() here?
Doesn't the libc include pretty much the same manual loop internally
anyway as a fallback?

Are you sure that writzev() is not async signal safe? Maybe this is just
a documentation oversight?

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list