openbsd-ports/mail/dovecot/patches/patch-src_lib_istream-tee_c
sthen 1603ca096a roll in fixes from upstream repo; from Brad.
- mail_index_lookup_first() didn't always find the result.
  This caused SELECT not to return UNSEEN number always.
- Maildir: Fix to earlier >26 keywords handling change.
- i_stream_read(): Added a few more asserts.
- istream-tee: Minor cleanups, assert and a potential fix.
2009-02-08 14:54:21 +00:00

38 lines
1.4 KiB
Plaintext

$OpenBSD: patch-src_lib_istream-tee_c,v 1.1 2009/02/08 14:54:21 sthen Exp $
--- src/lib/istream-tee.c.orig Thu Feb 5 16:21:43 2009
+++ src/lib/istream-tee.c Thu Feb 5 16:24:20 2009
@@ -112,12 +112,20 @@ static ssize_t i_stream_tee_read(struct istream_privat
uoff_t last_high_offset;
ssize_t ret;
+ if (stream->buffer == NULL) {
+ /* initial read */
+ tee_streams_update_buffer(tstream->tee);
+ }
data = i_stream_get_data(input, &size);
+ /* last_high_offset contains how far we have read this child tee stream
+ so far. input->v_offset + size contains how much is available in
+ the parent stream without having to read more. */
last_high_offset = stream->istream.v_offset +
- (tstream->istream.pos - tstream->istream.skip);
+ (stream->pos - stream->skip);
i_assert(last_high_offset <= input->v_offset + size);
if (last_high_offset == input->v_offset + size) {
+ /* we've read everything, need to read more */
tee_streams_skip(tstream->tee);
ret = i_stream_read(input);
if (ret <= 0) {
@@ -133,9 +141,9 @@ static ssize_t i_stream_tee_read(struct istream_privat
}
tee_streams_update_buffer(tstream->tee);
data = i_stream_get_data(input, &size);
- } else if (stream->buffer == NULL) {
- tee_streams_update_buffer(tstream->tee);
} else {
+ /* there's still some data available from parent */
+ i_assert(stream->pos < size);
stream->buffer = data;
}