file_write: Use para_open() and set the fd to non-blocking mode.
authorAndre Noll <maan@systemlinux.org>
Thu, 14 Jan 2010 00:19:12 +0000 (01:19 +0100)
committerAndre Noll <maan@systemlinux.org>
Thu, 14 Jan 2010 00:19:12 +0000 (01:19 +0100)
error.h
file_write.c

diff --git a/error.h b/error.h
index e47fa15..5a5d015 100644 (file)
--- a/error.h
+++ b/error.h
@@ -421,7 +421,6 @@ extern const char **para_errlist[];
 
 #define FILE_WRITE_ERRORS \
        PARA_ERROR(FW_WRITE, "file writer write error"), \
-       PARA_ERROR(FW_OPEN, "file writer: can not open output file"), \
        PARA_ERROR(FW_NO_FILE, "task started without open file"), \
 
 
index b12d07d..43cbf75 100644 (file)
@@ -56,19 +56,26 @@ static int file_write_open(struct writer_node *wn)
                sizeof(struct private_file_write_data));
        struct file_write_args_info *conf = wn->conf;
        char *filename;
+       int ret;
 
        if (conf->filename_given)
                filename = conf->filename_arg;
        else
                filename = random_filename();
        wn->private_data = pfwd;
-       pfwd->fd = open(filename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
+       ret = para_open(filename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
        if (!conf->filename_given)
                free(filename);
-       if (pfwd->fd >= 0)
+       if (ret < 0)
+               goto out;
+       pfwd->fd = ret;
+       ret = mark_fd_blocking(pfwd->fd);
+       if (ret >= 0)
                return 1;
+       close(pfwd->fd);
+out:
        free(pfwd);
-       return -E_FW_OPEN;
+       return ret;
 }
 
 static void file_write_pre_select(struct sched *s, struct task *t)