[dovecot-cvs]
dovecot/src/lib-storage/index/mbox istream-raw-mbox.c, 1.12, 1.13
cras at procontrol.fi
cras at procontrol.fi
Sun Jun 20 01:06:54 EEST 2004
Update of /home/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv13716
Modified Files:
istream-raw-mbox.c
Log Message:
read() less often
Index: istream-raw-mbox.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/istream-raw-mbox.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- istream-raw-mbox.c 19 Jun 2004 01:00:41 -0000 1.12
+++ istream-raw-mbox.c 19 Jun 2004 22:06:52 -0000 1.13
@@ -148,33 +148,38 @@
stream->skip = 0;
stream->buffer = NULL;
+ ret = 0;
do {
- ret = i_stream_read(rstream->input);
buf = i_stream_get_data(rstream->input, &pos);
- } while (ret > 0 && (pos == 1 ||
- stream->istream.v_offset + pos <=
- rstream->input_peak_offset));
+ if (pos > 1 &&
+ stream->istream.v_offset + pos > rstream->input_peak_offset)
+ break;
+ ret = i_stream_read(rstream->input);
+ } while (ret > 0);
if (ret < 0) {
- if (ret == -2)
- return -2;
-
- /* we've read the whole file, final byte should be
- the \n trailer */
- if (pos > 0 && buf[pos-1] == '\n')
- pos--;
+ if (ret == -2) {
+ if (stream->istream.v_offset + pos ==
+ rstream->input_peak_offset)
+ return -2;
+ } else {
+ /* we've read the whole file, final byte should be
+ the \n trailer */
+ if (pos > 0 && buf[pos-1] == '\n')
+ pos--;
- i_assert(pos >= stream->pos);
- ret = pos == stream->pos ? -1 :
- (ssize_t)(pos - stream->pos);
+ i_assert(pos >= stream->pos);
+ ret = pos == stream->pos ? -1 :
+ (ssize_t)(pos - stream->pos);
- stream->buffer = buf;
- stream->pos = pos;
+ stream->buffer = buf;
+ stream->pos = pos;
- rstream->eom = TRUE;
- rstream->eof = TRUE;
- handle_end_of_mail(rstream, pos);
- return ret < 0 ? _read(stream) : ret;
+ rstream->eom = TRUE;
+ rstream->eof = TRUE;
+ handle_end_of_mail(rstream, pos);
+ return ret < 0 ? _read(stream) : ret;
+ }
}
if (stream->istream.v_offset == rstream->from_offset) {
More information about the dovecot-cvs
mailing list