dovecot-2.1: istream-concat: If EOF is already reached, use that...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Jan 29 01:48:27 EET 2012
details: http://hg.dovecot.org/dovecot-2.1/rev/15bcb5616717
changeset: 14033:15bcb5616717
user: Timo Sirainen <tss at iki.fi>
date: Sun Jan 29 01:48:16 2012 +0200
description:
istream-concat: If EOF is already reached, use that size for stat().st_size
diffstat:
src/lib/istream-seekable.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diffs (40 lines):
diff -r 3c0bd1fd035b -r 15bcb5616717 src/lib/istream-seekable.c
--- a/src/lib/istream-seekable.c Sun Jan 29 01:37:44 2012 +0200
+++ b/src/lib/istream-seekable.c Sun Jan 29 01:48:16 2012 +0200
@@ -18,6 +18,7 @@
char *temp_path;
uoff_t write_peak;
+ uoff_t size;
int (*fd_callback)(const char **path_r, void *context);
void *context;
@@ -140,6 +141,7 @@
sstream->cur_input = sstream->input[sstream->cur_idx++];
if (sstream->cur_input == NULL) {
/* last one, EOF */
+ sstream->size = sstream->istream.istream.v_offset;
sstream->istream.istream.eof = TRUE;
return -1;
}
@@ -302,6 +304,12 @@
uoff_t old_offset;
ssize_t ret;
+ if (sstream->size != (uoff_t)-1) {
+ /* we've already reached EOF and know the size */
+ stream->statbuf.st_size = sstream->size;
+ return &stream->statbuf;
+ }
+
if (sstream->buffer != NULL) {
/* we want to know the full size of the file, so read until
we're finished */
@@ -365,6 +373,7 @@
sstream->buffer = buffer_create_dynamic(default_pool, BUF_INITIAL_SIZE);
sstream->istream.max_buffer_size = max_buffer_size;
sstream->fd = -1;
+ sstream->size = (uoff_t)-1;
sstream->input = i_new(struct istream *, count + 1);
memcpy(sstream->input, input, sizeof(*input) * count);
More information about the dovecot-cvs
mailing list