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) ...@@ -399,6 +399,7 @@ filter_ctl (struct _mu_stream *stream, int code, int opcode, void *ptr)
399 { 399 {
400 struct _mu_filter_stream *fs = (struct _mu_filter_stream *)stream; 400 struct _mu_filter_stream *fs = (struct _mu_filter_stream *)stream;
401 int status; 401 int status;
402 size_t dummy;
402 403
403 switch (code) 404 switch (code)
404 { 405 {
...@@ -406,6 +407,10 @@ filter_ctl (struct _mu_stream *stream, int code, int opcode, void *ptr) ...@@ -406,6 +407,10 @@ filter_ctl (struct _mu_stream *stream, int code, int opcode, void *ptr)
406 switch (opcode) 407 switch (opcode)
407 { 408 {
408 case MU_IOCTL_FILTER_SET_DISABLED: 409 case MU_IOCTL_FILTER_SET_DISABLED:
410 status = filter_write_internal (stream, mu_filter_flush,
411 NULL, 0, &dummy);
412 if (status)
413 return status;
409 if (ptr && *(int*)ptr) 414 if (ptr && *(int*)ptr)
410 fs->fltflag |= _MU_FILTER_DISABLED; 415 fs->fltflag |= _MU_FILTER_DISABLED;
411 else 416 else
......
...@@ -1156,7 +1156,10 @@ mu_stream_size (mu_stream_t stream, mu_off_t *psize) ...@@ -1156,7 +1156,10 @@ mu_stream_size (mu_stream_t stream, mu_off_t *psize)
1156 int 1156 int
1157 mu_stream_ioctl (mu_stream_t stream, int family, int opcode, void *ptr) 1157 mu_stream_ioctl (mu_stream_t stream, int family, int opcode, void *ptr)
1158 { 1158 {
1159 int rc;
1159 _bootstrap_event (stream); 1160 _bootstrap_event (stream);
1161 if ((rc = _stream_flush_buffer (stream, _MU_STR_FLUSH_ALL)))
1162 return rc;
1160 if (stream->ctl == NULL) 1163 if (stream->ctl == NULL)
1161 return ENOSYS; 1164 return ENOSYS;
1162 return stream->ctl (stream, family, opcode, ptr); 1165 return stream->ctl (stream, family, opcode, ptr);
......