From: Timo Sirainen Date: Tue, 19 Feb 2019 08:22:43 +0000 (+0200) Subject: lib-storage: mail_get_*stream*() - Assert that returned streams are blocking X-Git-Tag: 2.3.6~125 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c2f6ae2e1a30372b38772c32a21c22f293cb7e1b;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: mail_get_*stream*() - Assert that returned streams are blocking Several callers already rely on them being blocking. Making these asserts explicit makes sure that any bugs are caught early. --- diff --git a/src/lib-storage/mail.c b/src/lib-storage/mail.c index a5b4c386c2..1bb2390487 100644 --- a/src/lib-storage/mail.c +++ b/src/lib-storage/mail.c @@ -8,6 +8,7 @@ #include "crc32.h" #include "sha1.h" #include "hostpid.h" +#include "istream.h" #include "mail-cache.h" #include "mail-storage-private.h" #include "message-part-data.h" @@ -276,6 +277,7 @@ int mail_get_stream_because(struct mail *mail, struct message_size *hdr_size, ret = p->v.get_stream(mail, TRUE, hdr_size, body_size, stream_r); p->get_stream_reason = ""; } T_END; + i_assert(ret < 0 || (*stream_r)->blocking); return ret; } @@ -301,6 +303,7 @@ int mail_get_hdr_stream_because(struct mail *mail, ret = p->v.get_stream(mail, FALSE, hdr_size, NULL, stream_r); p->get_stream_reason = ""; } T_END; + i_assert(ret < 0 || (*stream_r)->blocking); return ret; } @@ -319,6 +322,7 @@ int mail_get_binary_stream(struct mail *mail, const struct message_part *part, ret = p->v.get_binary_stream(mail, part, include_hdr, size_r, NULL, binary_r, stream_r); } T_END; + i_assert(ret < 0 || (*stream_r)->blocking); return ret; }