From: Andre Noll Date: Thu, 14 Jan 2010 00:19:12 +0000 (+0100) Subject: file_write: Use para_open() and set the fd to non-blocking mode. X-Git-Tag: v0.4.2~102 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=4d222fe6d3bf328b27288de698f248c3a40d5c33;p=paraslash.git file_write: Use para_open() and set the fd to non-blocking mode. --- 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)