Mercurial > dovecot > core-2.2
changeset 15739:e7e95d2d2b37
fs-metawrap: Don't duplicate work if fs_get_metadata() is called multiple times.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 05 Feb 2013 03:30:01 +0200 |
parents | 1a6cf87eeff0 |
children | 397253f15f36 |
files | src/lib-fs/fs-metawrap.c src/lib-fs/istream-metawrap.c |
diffstat | 2 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-fs/fs-metawrap.c Tue Feb 05 03:24:45 2013 +0200 +++ b/src/lib-fs/fs-metawrap.c Tue Feb 05 03:30:01 2013 +0200 @@ -26,6 +26,7 @@ enum fs_open_mode open_mode; struct istream *input; struct ostream *super_output; + bool metadata_read; }; static void fs_metawrap_copy_error(struct metawrap_fs *fs) @@ -198,8 +199,10 @@ return 0; } - if (fs_read(_file, &c, 1) < 0) - return -1; + if (!file->metadata_read) { + if (fs_read(_file, &c, 1) < 0) + return -1; + } *metadata_r = &_file->metadata; return 0; } @@ -229,6 +232,11 @@ { struct metawrap_fs_file *file = context; + if (key == NULL) { + file->metadata_read = TRUE; + return; + } + T_BEGIN { key = str_tabunescape(t_strdup_noconst(key)); value = str_tabunescape(t_strdup_noconst(value));
--- a/src/lib-fs/istream-metawrap.c Tue Feb 05 03:24:45 2013 +0200 +++ b/src/lib-fs/istream-metawrap.c Tue Feb 05 03:30:01 2013 +0200 @@ -18,8 +18,10 @@ char *line, *p; while ((line = i_stream_read_next_line(mstream->istream.parent)) != NULL) { - if (*line == '\0') + if (*line == '\0') { + mstream->callback(NULL, NULL, mstream->context); return 1; + } p = strchr(line, ':'); if (p == NULL) { mstream->istream.istream.stream_errno = EINVAL;