file writer: Use xwrite() instead of plain write().
authorAndre Noll <maan@systemlinux.org>
Sat, 30 Mar 2013 19:12:40 +0000 (19:12 +0000)
committerAndre Noll <maan@systemlinux.org>
Sun, 19 May 2013 13:19:44 +0000 (15:19 +0200)
Currently the file writer's ->post_select() sets t->error to -1 on
errors, rather than using a proper error code. This may result in
a segfault when this number is passed to para_strerror().

Replacing the call to write() by xwrite() not only gives a proper
error code but also treats EAGAIN as a non-fatal error.

file_write.c

index 28fddcb6a518fc2869271d26703dcaf02f73d481..cea21cb3f5e182798f922b8234aa49977c85ba6b 100644 (file)
@@ -122,7 +122,7 @@ static int file_write_post_select(__a_unused struct sched *s,
        bytes = btr_next_buffer(btrn, &buf);
        assert(bytes > 0);
        //PARA_INFO_LOG("writing %zu\n", bytes);
        bytes = btr_next_buffer(btrn, &buf);
        assert(bytes > 0);
        //PARA_INFO_LOG("writing %zu\n", bytes);
-       ret = write(pfwd->fd, buf, bytes);
+       ret = xwrite(pfwd->fd, buf, bytes);
        if (ret < 0)
                goto out;
        btr_consume(btrn, ret);
        if (ret < 0)
                goto out;
        btr_consume(btrn, ret);