X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=file_write.c;h=9a5ed5d7fab7dc01fe46fa5ecab6940ea3a28828;hb=refs%2Fheads%2Fpu;hp=9837e810278ee220fce4a313d695db3b9772f3ad;hpb=bd28ec9a64884d70917c4fdea1a3a70c91758f83;p=paraslash.git diff --git a/file_write.c b/file_write.c index 9837e810..0a5d6bba 100644 --- a/file_write.c +++ b/file_write.c @@ -1,8 +1,4 @@ -/* - * Copyright (C) 2006 Andre Noll - * - * Licensed under the GPL v2. For licencing details see COPYING. - */ +/* Copyright (C) 2006 Andre Noll , see file COPYING. */ /** \file file_write.c simple output plugin for testing purposes */ @@ -35,13 +31,8 @@ struct private_file_write_data { */ __must_check __malloc static char *random_filename(void) { - char *result, *home = para_homedir(); - srandom(clock_get_realtime(NULL)->tv_usec); - result = make_message("%s/.paraslash/%08ld", home, - para_random(99999999)); - free(home); - return result; + return make_message("%s/%08ld", get_confdir(), para_random(99999999)); } static int prepare_output_file(struct writer_node *wn) @@ -68,12 +59,12 @@ static int prepare_output_file(struct writer_node *wn) close(fd); return ret; } - pfwd = wn->private_data = para_calloc(sizeof(*pfwd)); + pfwd = wn->private_data = zalloc(sizeof(*pfwd)); pfwd->fd = fd; return 1; } -static void file_write_pre_select(struct sched *s, void *context) +static void file_write_pre_monitor(struct sched *s, void *context) { struct writer_node *wn = context; struct private_file_write_data *pfwd = wn->private_data; @@ -83,7 +74,7 @@ static void file_write_pre_select(struct sched *s, void *context) return; if (ret < 0 || !pfwd) return sched_min_delay(s); - para_fd_set(pfwd->fd, &s->wfds, &s->max_fileno); + sched_monitor_writefd(pfwd->fd, s); } static void file_write_close(struct writer_node *wn) @@ -96,7 +87,7 @@ static void file_write_close(struct writer_node *wn) free(pfwd); } -static int file_write_post_select(__a_unused struct sched *s, void *context) +static int file_write_post_monitor(__a_unused struct sched *s, void *context) { struct writer_node *wn = context; struct private_file_write_data *pfwd = wn->private_data; @@ -115,7 +106,7 @@ static int file_write_post_select(__a_unused struct sched *s, void *context) ret = prepare_output_file(wn); goto out; } - if (!FD_ISSET(pfwd->fd, &s->wfds)) + if (!sched_write_ok(pfwd->fd, s)) return 0; bytes = btr_next_buffer(btrn, &buf); assert(bytes > 0); @@ -132,7 +123,7 @@ out: /** the init function of the file writer */ struct writer lsg_write_cmd_com_file_user_data = { - .pre_select = file_write_pre_select, - .post_select = file_write_post_select, + .pre_monitor = file_write_pre_monitor, + .post_monitor = file_write_post_monitor, .close = file_write_close, };