Commit 1cbbd572 1cbbd572d56b7a77362992181ef008db8a11688f by Sergey Poznyakoff

Ensure consisten stream state before calling its ctl method.

Prior to calling ctl method, mu_stream_ioctl flushes stream
buffer.

* libmailutils/stream/fltstream.c (filter_ctl)
<MU_IOCTL_FILTER_SET_DISABLED>: Flush internal buffer prior to
setting the flag.
* libmailutils/stream/stream.c (mu_stream_ioctl): Flush stream
buffer.
1 parent 6e2a3758
......@@ -399,6 +399,7 @@ filter_ctl (struct _mu_stream *stream, int code, int opcode, void *ptr)
{
struct _mu_filter_stream *fs = (struct _mu_filter_stream *)stream;
int status;
size_t dummy;
switch (code)
{
......@@ -406,6 +407,10 @@ filter_ctl (struct _mu_stream *stream, int code, int opcode, void *ptr)
switch (opcode)
{
case MU_IOCTL_FILTER_SET_DISABLED:
status = filter_write_internal (stream, mu_filter_flush,
NULL, 0, &dummy);
if (status)
return status;
if (ptr && *(int*)ptr)
fs->fltflag |= _MU_FILTER_DISABLED;
else
......
......@@ -1156,7 +1156,10 @@ mu_stream_size (mu_stream_t stream, mu_off_t *psize)
int
mu_stream_ioctl (mu_stream_t stream, int family, int opcode, void *ptr)
{
int rc;
_bootstrap_event (stream);
if ((rc = _stream_flush_buffer (stream, _MU_STR_FLUSH_ALL)))
return rc;
if (stream->ctl == NULL)
return ENOSYS;
return stream->ctl (stream, family, opcode, ptr);
......