From 3996ade63e3d7a37791dc809f92655a031a25436 Mon Sep 17 00:00:00 2001 From: leitner Date: Wed, 25 Feb 2004 02:22:54 +0000 Subject: [PATCH] add iob_addfile_close (iob_reset will close the files) --- io/iob_addfile_close.c | 15 +++++++++++++++ io/iob_prefetch.c | 2 +- io/iob_reset.c | 2 ++ io/iob_send.c | 6 +++--- iob.h | 1 + iob_internal.h | 2 +- 6 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 io/iob_addfile_close.c diff --git a/io/iob_addfile_close.c b/io/iob_addfile_close.c new file mode 100644 index 0000000..9df76da --- /dev/null +++ b/io/iob_addfile_close.c @@ -0,0 +1,15 @@ +#include "iob_internal.h" + +int iob_addfile_close(io_batch* b,int64 fd,uint64 off,uint64 n) { + iob_entry* e=array_allocate(&b->b,sizeof(iob_entry), + array_length(&b->b,sizeof(iob_entry))); + if (!e) return 0; + e->type=FROMFILE_CLOSE; + e->fd=fd; + e->buf=0; + e->n=n; + e->offset=off; + b->bytesleft+=n; + ++b->files; + return 1; +} diff --git a/io/iob_prefetch.c b/io/iob_prefetch.c index b16db6f..53ac735 100644 --- a/io/iob_prefetch.c +++ b/io/iob_prefetch.c @@ -11,7 +11,7 @@ void iob_prefetch(io_batch* b,uint64 bytes) { e=(iob_entry*)array_start(&b->b); if (!e) return; for (; etype==FROMFILE) { + if (e->type==FROMFILE || e->type==FROMFILE_CLOSE) { char* c,* d; uint64 before=bytes; if (e->nn; diff --git a/io/iob_reset.c b/io/iob_reset.c index 00a722d..2f99424 100644 --- a/io/iob_reset.c +++ b/io/iob_reset.c @@ -9,6 +9,8 @@ void iob_reset(io_batch* b) { for (i=0; ib); byte_zero(b,sizeof(*b)); diff --git a/io/iob_send.c b/io/iob_send.c index 74cd5af..855ca20 100644 --- a/io/iob_send.c +++ b/io/iob_send.c @@ -36,18 +36,18 @@ int64 iob_send(int64 s,io_batch* b) { headers=trailers=0; #endif for (i=0; e+i