From 4d222fe6d3bf328b27288de698f248c3a40d5c33 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Thu, 14 Jan 2010 01:19:12 +0100 Subject: [PATCH] file_write: Use para_open() and set the fd to non-blocking mode. --- error.h | 1 - file_write.c | 13 ++++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/error.h b/error.h index e47fa152..5a5d015d 100644 --- 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"), \ diff --git a/file_write.c b/file_write.c index b12d07d5..43cbf759 100644 --- a/file_write.c +++ b/file_write.c @@ -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) -- 2.39.2