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

Kay Sievers kay at vrfy.org
Tue Jan 28 03:23:00 PST 2014


On Sun, Jan 26, 2014 at 6:21 AM, 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;
> +}

What kind of logic are you following here? Looping in userspace over n
syscall is safer than calling one single syscall?

Unless you can explain the magic here, please don't do things like that.

Kay


More information about the systemd-devel mailing list