Commit 841fc484 841fc4842ae81579edab2a7752b0347944575d2c by Sergey Poznyakoff

Remove MU_STREAM_AUTOCLOSE flag. Use mu_stream_unref, if necessary.

* examples/mta.c: Use MU_STREAM_FD_AUTOCLOSE.
* imap4d/io.c: Likewise.
* libmailutils/stream/file_stream.c: Likewise.
* libmailutils/stream/prog_stream.c: Likewise.
* libmailutils/stream/socket_stream.c: Likewise.
* libmailutils/stream/temp_file_stream.c: Likewise.
* maidag/lmtp.c: Likewise.
* pop3d/extra.c: Likewise.

* imap4d/preauth.c: Do not use MU_STREAM_AUTOCLOSE.  Instead unref the
transport stream after creating the derived one.
* libmailutils/base/rfc2047.c: Likewise.
* libmailutils/stream/fltstream.c: Likewise.
* libmailutils/tests/fltst.c: Likewise.
* libmu_auth/ldap.c: Likewise.
* libmu_auth/tls.c: Likewise.
* libmu_sieve/extensions/vacation.c: Likewise.
* libproto/pop/pop3_stream.c: Likewise.
* mail/decode.c: Likewise.
* mh/mhn.c: Likewise.

* libmailutils/filter/filter_iconv.c: Do not handle MU_STREAM_AUTOCLOSE.
* libmailutils/stream/rdcache_stream.c: Likewise.
* libmailutils/stream/streamref.c: Likewise.
* libmailutils/stream/xscript-stream.c: Likewise.

* include/mailutils/stream.h (MU_STREAM_AUTOCLOSE): Rename to
MU_STREAM_FD_AUTOCLOSE.
1 parent 8f8d9036
...@@ -570,13 +570,9 @@ eval_biffrc (struct biffrc_environ *env) ...@@ -570,13 +570,9 @@ eval_biffrc (struct biffrc_environ *env)
570 if (!sp) 570 if (!sp)
571 report_error (env, _("unknown keyword")); 571 report_error (env, _("unknown keyword"));
572 else if (ws.ws_wordc < sp->argmin) 572 else if (ws.ws_wordc < sp->argmin)
573 { 573 report_error (env, _("too few arguments"));
574 report_error (env, _("too few arguments"));
575 }
576 else if (sp->argmax != -1 && ws.ws_wordc > sp->argmax) 574 else if (sp->argmax != -1 && ws.ws_wordc > sp->argmax)
577 { 575 report_error (env, _("too many arguments"));
578 report_error (env, _("too many arguments"));
579 }
580 else 576 else
581 { 577 {
582 if (sp->expand) 578 if (sp->expand)
......
...@@ -825,7 +825,7 @@ mta_smtp (int argc, char **argv) ...@@ -825,7 +825,7 @@ mta_smtp (int argc, char **argv)
825 } 825 }
826 826
827 rc = mu_fd_stream_create (&str, NULL, sfd, 827 rc = mu_fd_stream_create (&str, NULL, sfd,
828 MU_STREAM_RDWR|MU_STREAM_AUTOCLOSE); 828 MU_STREAM_RDWR|MU_STREAM_FD_AUTOCLOSE);
829 if (rc) 829 if (rc)
830 { 830 {
831 mu_diag_funcall (MU_DIAG_ERROR, "mu_fd_stream_create", NULL, rc); 831 mu_diag_funcall (MU_DIAG_ERROR, "mu_fd_stream_create", NULL, rc);
......
...@@ -30,12 +30,12 @@ io_setio (int ifd, int ofd) ...@@ -30,12 +30,12 @@ io_setio (int ifd, int ofd)
30 imap4d_bye (ERR_NO_OFILE); 30 imap4d_bye (ERR_NO_OFILE);
31 31
32 if (mu_stdio_stream_create (&istream, ifd, 32 if (mu_stdio_stream_create (&istream, ifd,
33 MU_STREAM_READ | MU_STREAM_AUTOCLOSE)) 33 MU_STREAM_READ | MU_STREAM_FD_AUTOCLOSE))
34 imap4d_bye (ERR_STREAM_CREATE); 34 imap4d_bye (ERR_STREAM_CREATE);
35 mu_stream_set_buffer (istream, mu_buffer_line, 0); 35 mu_stream_set_buffer (istream, mu_buffer_line, 0);
36 36
37 if (mu_stdio_stream_create (&ostream, ofd, 37 if (mu_stdio_stream_create (&ostream, ofd,
38 MU_STREAM_WRITE | MU_STREAM_AUTOCLOSE)) 38 MU_STREAM_WRITE | MU_STREAM_FD_AUTOCLOSE))
39 imap4d_bye (ERR_STREAM_CREATE); 39 imap4d_bye (ERR_STREAM_CREATE);
40 mu_stream_set_buffer (ostream, mu_buffer_line, 0); 40 mu_stream_set_buffer (ostream, mu_buffer_line, 0);
41 41
......
...@@ -193,8 +193,8 @@ decode64_buf (const char *name, unsigned char **pbuf, size_t *psize) ...@@ -193,8 +193,8 @@ decode64_buf (const char *name, unsigned char **pbuf, size_t *psize)
193 name++; 193 name++;
194 namelen = strlen (name) - 1; 194 namelen = strlen (name) - 1;
195 mu_static_memory_stream_create (&str, name, namelen); 195 mu_static_memory_stream_create (&str, name, namelen);
196 mu_filter_create (&flt, str, "base64", MU_FILTER_DECODE, 196 mu_filter_create (&flt, str, "base64", MU_FILTER_DECODE, MU_STREAM_READ);
197 MU_STREAM_READ | MU_STREAM_AUTOCLOSE); 197 mu_stream_unref (str);
198 mu_stream_read (flt, buf, sizeof buf, &size); 198 mu_stream_read (flt, buf, sizeof buf, &size);
199 mu_stream_destroy (&flt); 199 mu_stream_destroy (&flt);
200 *pbuf = malloc (size); 200 *pbuf = malloc (size);
......
...@@ -43,7 +43,8 @@ enum mu_buffer_type ...@@ -43,7 +43,8 @@ enum mu_buffer_type
43 #define MU_STREAM_CREAT 0x00000010 43 #define MU_STREAM_CREAT 0x00000010
44 /* So far used only by TCP streams. */ 44 /* So far used only by TCP streams. */
45 #define MU_STREAM_NONBLOCK 0x00000020 45 #define MU_STREAM_NONBLOCK 0x00000020
46 #define MU_STREAM_AUTOCLOSE 0x00000040 46 /* For fd streams only */
47 #define MU_STREAM_FD_AUTOCLOSE 0x00000040
47 /* Not used. Intended for mailboxes only. */ 48 /* Not used. Intended for mailboxes only. */
48 #define MU_STREAM_NONLOCK 0x00000080 49 #define MU_STREAM_NONLOCK 0x00000080
49 /* Not used as well 0x00000100 */ 50 /* Not used as well 0x00000100 */
......
...@@ -269,8 +269,8 @@ mu_rfc2047_encode (const char *charset, const char *encoding, ...@@ -269,8 +269,8 @@ mu_rfc2047_encode (const char *charset, const char *encoding,
269 if (rc) 269 if (rc)
270 return rc; 270 return rc;
271 rc = mu_filter_create (&output_stream, input_stream, 271 rc = mu_filter_create (&output_stream, input_stream,
272 encoding, MU_FILTER_ENCODE, 272 encoding, MU_FILTER_ENCODE, MU_STREAM_READ);
273 MU_STREAM_READ | MU_STREAM_AUTOCLOSE); 273 mu_stream_unref (input_stream);
274 if (rc == 0) 274 if (rc == 0)
275 { 275 {
276 /* Assume strlen(qp_encoded_text) <= strlen(text) * 3 */ 276 /* Assume strlen(qp_encoded_text) <= strlen(text) * 3 */
......
...@@ -453,8 +453,7 @@ mu_filter_iconv_create (mu_stream_t *s, mu_stream_t transport, ...@@ -453,8 +453,7 @@ mu_filter_iconv_create (mu_stream_t *s, mu_stream_t transport,
453 return ENOMEM; 453 return ENOMEM;
454 } 454 }
455 455
456 if (!(flags & MU_STREAM_AUTOCLOSE)) 456 mu_stream_ref (transport);
457 mu_stream_ref (transport);
458 iptr->transport = transport; 457 iptr->transport = transport;
459 iptr->fallback_mode = fallback_mode; 458 iptr->fallback_mode = fallback_mode;
460 iptr->cd = cd; 459 iptr->cd = cd;
......
...@@ -65,7 +65,7 @@ fd_close (struct _mu_stream *str) ...@@ -65,7 +65,7 @@ fd_close (struct _mu_stream *str)
65 struct _mu_file_stream *fstr = (struct _mu_file_stream *) str; 65 struct _mu_file_stream *fstr = (struct _mu_file_stream *) str;
66 if (fstr->fd != -1) 66 if (fstr->fd != -1)
67 { 67 {
68 if ((str->flags & MU_STREAM_AUTOCLOSE) && close (fstr->fd)) 68 if ((str->flags & MU_STREAM_FD_AUTOCLOSE) && close (fstr->fd))
69 return errno; 69 return errno;
70 fstr->fd = -1; 70 fstr->fd = -1;
71 } 71 }
...@@ -119,7 +119,7 @@ fd_open (struct _mu_stream *str) ...@@ -119,7 +119,7 @@ fd_open (struct _mu_stream *str)
119 str->flags &= ~MU_STREAM_SEEK; 119 str->flags &= ~MU_STREAM_SEEK;
120 120
121 /* Make sure it will be closed */ 121 /* Make sure it will be closed */
122 str->flags |= MU_STREAM_AUTOCLOSE; 122 str->flags |= MU_STREAM_FD_AUTOCLOSE;
123 123
124 fstr->fd = fd; 124 fstr->fd = fd;
125 return 0; 125 return 0;
...@@ -331,7 +331,8 @@ mu_file_stream_create (mu_stream_t *pstream, const char *filename, int flags) ...@@ -331,7 +331,8 @@ mu_file_stream_create (mu_stream_t *pstream, const char *filename, int flags)
331 int rc = _mu_file_stream_create (&fstr, 331 int rc = _mu_file_stream_create (&fstr,
332 sizeof (struct _mu_file_stream), 332 sizeof (struct _mu_file_stream),
333 filename, -1, 333 filename, -1,
334 flags | MU_STREAM_SEEK | MU_STREAM_AUTOCLOSE); 334 flags | MU_STREAM_SEEK |
335 MU_STREAM_FD_AUTOCLOSE);
335 if (rc == 0) 336 if (rc == 0)
336 { 337 {
337 mu_stream_t stream = (mu_stream_t) fstr; 338 mu_stream_t stream = (mu_stream_t) fstr;
......
...@@ -520,8 +520,7 @@ mu_filter_stream_create (mu_stream_t *pflt, ...@@ -520,8 +520,7 @@ mu_filter_stream_create (mu_stream_t *pflt,
520 fs->stream.error_string = filter_error_string; 520 fs->stream.error_string = filter_error_string;
521 fs->stream.flags = flags; 521 fs->stream.flags = flags;
522 522
523 if (!(flags & MU_STREAM_AUTOCLOSE)) 523 mu_stream_ref (str);
524 mu_stream_ref (str);
525 fs->transport = str; 524 fs->transport = str;
526 fs->xcode = xcode; 525 fs->xcode = xcode;
527 fs->xdata = xdata; 526 fs->xdata = xdata;
......
...@@ -440,7 +440,7 @@ _prog_open (mu_stream_t stream) ...@@ -440,7 +440,7 @@ _prog_open (mu_stream_t stream)
440 if (REDIRECT_STDOUT_P (flags)) 440 if (REDIRECT_STDOUT_P (flags))
441 { 441 {
442 rc = mu_stdio_stream_create (&fs->in, pfd[0], 442 rc = mu_stdio_stream_create (&fs->in, pfd[0],
443 MU_STREAM_READ|MU_STREAM_AUTOCLOSE|seekable_flag); 443 MU_STREAM_READ|MU_STREAM_FD_AUTOCLOSE|seekable_flag);
444 if (rc) 444 if (rc)
445 { 445 {
446 _prog_close (stream); 446 _prog_close (stream);
...@@ -451,7 +451,7 @@ _prog_open (mu_stream_t stream) ...@@ -451,7 +451,7 @@ _prog_open (mu_stream_t stream)
451 if (REDIRECT_STDIN_P (flags)) 451 if (REDIRECT_STDIN_P (flags))
452 { 452 {
453 rc = mu_stdio_stream_create (&fs->out, pfd[1], 453 rc = mu_stdio_stream_create (&fs->out, pfd[1],
454 MU_STREAM_WRITE|MU_STREAM_AUTOCLOSE|seekable_flag); 454 MU_STREAM_WRITE|MU_STREAM_FD_AUTOCLOSE|seekable_flag);
455 if (rc) 455 if (rc)
456 { 456 {
457 _prog_close (stream); 457 _prog_close (stream);
......
...@@ -188,7 +188,7 @@ mu_rdcache_stream_create (mu_stream_t *pstream, mu_stream_t transport, ...@@ -188,7 +188,7 @@ mu_rdcache_stream_create (mu_stream_t *pstream, mu_stream_t transport,
188 { 188 {
189 struct _mu_rdcache_stream *sp; 189 struct _mu_rdcache_stream *sp;
190 int rc; 190 int rc;
191 int sflags = MU_STREAM_READ | MU_STREAM_SEEK | (flags & MU_STREAM_AUTOCLOSE); 191 int sflags = MU_STREAM_READ | MU_STREAM_SEEK;
192 192
193 if (flags & ~sflags) 193 if (flags & ~sflags)
194 return EINVAL; 194 return EINVAL;
...@@ -207,8 +207,7 @@ mu_rdcache_stream_create (mu_stream_t *pstream, mu_stream_t transport, ...@@ -207,8 +207,7 @@ mu_rdcache_stream_create (mu_stream_t *pstream, mu_stream_t transport,
207 sp->stream.ctl = rdcache_ioctl; 207 sp->stream.ctl = rdcache_ioctl;
208 sp->stream.wait = rdcache_wait; 208 sp->stream.wait = rdcache_wait;
209 209
210 if (!(flags & MU_STREAM_AUTOCLOSE)) 210 mu_stream_ref (transport);
211 mu_stream_ref (transport);
212 sp->transport = transport; 211 sp->transport = transport;
213 212
214 if ((rc = mu_memory_stream_create (&sp->cache, MU_STREAM_RDWR))) 213 if ((rc = mu_memory_stream_create (&sp->cache, MU_STREAM_RDWR)))
......
...@@ -99,7 +99,8 @@ mu_socket_stream_create (mu_stream_t *pstream, const char *filename, int flags) ...@@ -99,7 +99,8 @@ mu_socket_stream_create (mu_stream_t *pstream, const char *filename, int flags)
99 /* Create transport stream. */ 99 /* Create transport stream. */
100 rc = _mu_file_stream_create (&fstr, sizeof (*fstr), 100 rc = _mu_file_stream_create (&fstr, sizeof (*fstr),
101 filename, -1, 101 filename, -1,
102 (flags | MU_STREAM_AUTOCLOSE) & ~MU_STREAM_SEEK); 102 (flags | MU_STREAM_FD_AUTOCLOSE) &
103 ~MU_STREAM_SEEK);
103 if (rc) 104 if (rc)
104 return rc; 105 return rc;
105 fstr->stream.open = _socket_open; 106 fstr->stream.open = _socket_open;
......
...@@ -280,8 +280,7 @@ mu_streamref_create_abridged (mu_stream_t *pref, mu_stream_t str, ...@@ -280,8 +280,7 @@ mu_streamref_create_abridged (mu_stream_t *pref, mu_stream_t str,
280 return rc; 280 return rc;
281 mu_stream_get_flags (str, &flags); 281 mu_stream_get_flags (str, &flags);
282 sp = (struct _mu_streamref *) 282 sp = (struct _mu_streamref *)
283 _mu_stream_create (sizeof (*sp), 283 _mu_stream_create (sizeof (*sp), flags | _MU_STR_OPEN);
284 (flags & ~MU_STREAM_AUTOCLOSE) | _MU_STR_OPEN);
285 if (!sp) 284 if (!sp)
286 return ENOMEM; 285 return ENOMEM;
287 286
......
...@@ -68,7 +68,7 @@ mu_temp_file_stream_create (mu_stream_t *pstream, ...@@ -68,7 +68,7 @@ mu_temp_file_stream_create (mu_stream_t *pstream,
68 -1, 68 -1,
69 MU_STREAM_RDWR | MU_STREAM_SEEK | 69 MU_STREAM_RDWR | MU_STREAM_SEEK |
70 MU_STREAM_CREAT | 70 MU_STREAM_CREAT |
71 MU_STREAM_AUTOCLOSE); 71 MU_STREAM_FD_AUTOCLOSE);
72 if (rc == 0) 72 if (rc == 0)
73 { 73 {
74 struct _mu_temp_file_stream *tstr = (struct _mu_temp_file_stream *)str; 74 struct _mu_temp_file_stream *tstr = (struct _mu_temp_file_stream *)str;
......
...@@ -438,11 +438,9 @@ mu_xscript_stream_create(mu_stream_t *pref, mu_stream_t transport, ...@@ -438,11 +438,9 @@ mu_xscript_stream_create(mu_stream_t *pref, mu_stream_t transport,
438 sp->stream.event_cb = _xscript_event_cb; 438 sp->stream.event_cb = _xscript_event_cb;
439 sp->stream.event_mask = _MU_STR_EVMASK(_MU_STR_EVENT_FILLBUF) | 439 sp->stream.event_mask = _MU_STR_EVMASK(_MU_STR_EVENT_FILLBUF) |
440 _MU_STR_EVMASK(_MU_STR_EVENT_FLUSHBUF); 440 _MU_STR_EVMASK(_MU_STR_EVENT_FLUSHBUF);
441 if (!(flags & MU_STREAM_AUTOCLOSE)) 441 mu_stream_ref (transport);
442 { 442 mu_stream_ref (logstr);
443 mu_stream_ref (transport); 443
444 mu_stream_ref (logstr);
445 }
446 sp->transport = transport; 444 sp->transport = transport;
447 sp->logstr = logstr; 445 sp->logstr = logstr;
448 446
......
...@@ -148,8 +148,8 @@ main (int argc, char * argv []) ...@@ -148,8 +148,8 @@ main (int argc, char * argv [])
148 MU_ASSERT (mu_filter_create_args (&flt, in, fltname, 148 MU_ASSERT (mu_filter_create_args (&flt, in, fltname,
149 argc, (const char **)argv, 149 argc, (const char **)argv,
150 mode, 150 mode,
151 MU_STREAM_READ|MU_STREAM_SEEK| 151 MU_STREAM_READ|MU_STREAM_SEEK));
152 MU_STREAM_AUTOCLOSE)); 152 mu_stream_unref (in);
153 if (shift) 153 if (shift)
154 MU_ASSERT (mu_stream_seek (flt, shift, MU_SEEK_SET, NULL)); 154 MU_ASSERT (mu_stream_seek (flt, shift, MU_SEEK_SET, NULL));
155 c_copy (out, flt); 155 c_copy (out, flt);
......
...@@ -599,8 +599,8 @@ chk_md5 (const char *db_pass, const char *pass) ...@@ -599,8 +599,8 @@ chk_md5 (const char *db_pass, const char *pass)
599 mu_md5_finish_ctx (&md5context, md5digest); 599 mu_md5_finish_ctx (&md5context, md5digest);
600 600
601 mu_static_memory_stream_create (&str, db_pass, strlen (db_pass)); 601 mu_static_memory_stream_create (&str, db_pass, strlen (db_pass));
602 mu_filter_create (&flt, str, "base64", MU_FILTER_DECODE, 602 mu_filter_create (&flt, str, "base64", MU_FILTER_DECODE, MU_STREAM_READ);
603 MU_STREAM_READ | MU_STREAM_AUTOCLOSE); 603 mu_stream_unref (str);
604 604
605 mu_stream_read (flt, (char*) d1, sizeof d1, NULL); 605 mu_stream_read (flt, (char*) d1, sizeof d1, NULL);
606 mu_stream_destroy (&flt); 606 mu_stream_destroy (&flt);
...@@ -621,8 +621,8 @@ chk_smd5 (const char *db_pass, const char *pass) ...@@ -621,8 +621,8 @@ chk_smd5 (const char *db_pass, const char *pass)
621 621
622 size = strlen (db_pass); 622 size = strlen (db_pass);
623 mu_static_memory_stream_create (&str, db_pass, size); 623 mu_static_memory_stream_create (&str, db_pass, size);
624 mu_filter_create (&flt, str, "base64", MU_FILTER_DECODE, 624 mu_filter_create (&flt, str, "base64", MU_FILTER_DECODE, MU_STREAM_READ);
625 MU_STREAM_READ | MU_STREAM_AUTOCLOSE); 625 mu_stream_unref (str);
626 626
627 d1 = malloc (size); 627 d1 = malloc (size);
628 if (!d1) 628 if (!d1)
...@@ -664,8 +664,8 @@ chk_sha (const char *db_pass, const char *pass) ...@@ -664,8 +664,8 @@ chk_sha (const char *db_pass, const char *pass)
664 mu_sha1_finish_ctx (&sha1context, sha1digest); 664 mu_sha1_finish_ctx (&sha1context, sha1digest);
665 665
666 mu_static_memory_stream_create (&str, db_pass, strlen (db_pass)); 666 mu_static_memory_stream_create (&str, db_pass, strlen (db_pass));
667 mu_filter_create (&flt, str, "base64", MU_FILTER_DECODE, 667 mu_filter_create (&flt, str, "base64", MU_FILTER_DECODE, MU_STREAM_READ);
668 MU_STREAM_READ | MU_STREAM_AUTOCLOSE); 668 mu_stream_unref (str);
669 669
670 mu_stream_read (flt, (char*) d1, sizeof d1, NULL); 670 mu_stream_read (flt, (char*) d1, sizeof d1, NULL);
671 mu_stream_destroy (&flt); 671 mu_stream_destroy (&flt);
...@@ -686,8 +686,8 @@ chk_ssha (const char *db_pass, const char *pass) ...@@ -686,8 +686,8 @@ chk_ssha (const char *db_pass, const char *pass)
686 686
687 size = strlen (db_pass); 687 size = strlen (db_pass);
688 mu_static_memory_stream_create (&str, db_pass, size); 688 mu_static_memory_stream_create (&str, db_pass, size);
689 mu_filter_create (&flt, str, "base64", MU_FILTER_DECODE, 689 mu_filter_create (&flt, str, "base64", MU_FILTER_DECODE, MU_STREAM_READ);
690 MU_STREAM_READ | MU_STREAM_AUTOCLOSE); 690 mu_stream_unref (str);
691 691
692 d1 = malloc (size); 692 d1 = malloc (size);
693 if (!d1) 693 if (!d1)
......
...@@ -327,8 +327,7 @@ _mu_tls_io_stream_create (mu_stream_t *pstream, ...@@ -327,8 +327,7 @@ _mu_tls_io_stream_create (mu_stream_t *pstream,
327 /* FIXME: 327 /* FIXME:
328 sp->stream.error_string = _tls_error_string;*/ 328 sp->stream.error_string = _tls_error_string;*/
329 329
330 if (!(flags & MU_STREAM_AUTOCLOSE)) 330 mu_stream_ref (transport);
331 mu_stream_ref (transport);
332 sp->transport = transport; 331 sp->transport = transport;
333 sp->up = master; 332 sp->up = master;
334 *pstream = (mu_stream_t) sp; 333 *pstream = (mu_stream_t) sp;
...@@ -642,7 +641,6 @@ _mu_tls_stream_create (mu_stream_t *pstream, ...@@ -642,7 +641,6 @@ _mu_tls_stream_create (mu_stream_t *pstream,
642 mu_stream_t strin, mu_stream_t strout, int flags) 641 mu_stream_t strin, mu_stream_t strout, int flags)
643 { 642 {
644 struct _mu_tls_stream *sp; 643 struct _mu_tls_stream *sp;
645 int autoclose = flags & MU_STREAM_AUTOCLOSE;
646 int rc; 644 int rc;
647 mu_stream_t stream; 645 mu_stream_t stream;
648 646
...@@ -664,16 +662,15 @@ _mu_tls_stream_create (mu_stream_t *pstream, ...@@ -664,16 +662,15 @@ _mu_tls_stream_create (mu_stream_t *pstream,
664 662
665 mu_stream_set_buffer (strin, mu_buffer_none, 0); 663 mu_stream_set_buffer (strin, mu_buffer_none, 0);
666 mu_stream_set_buffer (strout, mu_buffer_none, 0); 664 mu_stream_set_buffer (strout, mu_buffer_none, 0);
667 rc = _mu_tls_io_stream_create (&sp->transport[0], strin, 665 rc = _mu_tls_io_stream_create (&sp->transport[0], strin, MU_STREAM_READ, sp);
668 MU_STREAM_READ | autoclose, sp);
669 if (rc) 666 if (rc)
670 { 667 {
671 free (sp); 668 free (sp);
672 return rc; 669 return rc;
673 } 670 }
674 671
675 rc = _mu_tls_io_stream_create (&sp->transport[1], strout, 672 rc = _mu_tls_io_stream_create (&sp->transport[1], strout, MU_STREAM_WRITE,
676 MU_STREAM_WRITE | autoclose, sp); 673 sp);
677 if (rc) 674 if (rc)
678 { 675 {
679 free (sp); 676 free (sp);
......
...@@ -75,7 +75,8 @@ build_mime (mu_sieve_machine_t mach, mu_list_t tags, mu_mime_t *pmime, ...@@ -75,7 +75,8 @@ build_mime (mu_sieve_machine_t mach, mu_list_t tags, mu_mime_t *pmime,
75 mu_stream_t fstr; 75 mu_stream_t fstr;
76 rc = mu_filter_create (&fstr, input, "base64", 76 rc = mu_filter_create (&fstr, input, "base64",
77 MU_FILTER_ENCODE, 77 MU_FILTER_ENCODE,
78 MU_STREAM_READ | MU_STREAM_AUTOCLOSE); 78 MU_STREAM_READ);
79 mu_stream_unref (input);
79 if (rc == 0) 80 if (rc == 0)
80 { 81 {
81 header = "Content-Type: text/plain;charset=" MU_SIEVE_CHARSET "\n" 82 header = "Content-Type: text/plain;charset=" MU_SIEVE_CHARSET "\n"
......
...@@ -73,7 +73,8 @@ mu_pop3_filter_create (mu_stream_t *pstream, mu_stream_t stream) ...@@ -73,7 +73,8 @@ mu_pop3_filter_create (mu_stream_t *pstream, mu_stream_t stream)
73 int rc; 73 int rc;
74 74
75 rc = mu_filter_create (pstream, stream, "CRLFDOT", MU_FILTER_DECODE, 75 rc = mu_filter_create (pstream, stream, "CRLFDOT", MU_FILTER_DECODE,
76 MU_STREAM_READ | MU_STREAM_AUTOCLOSE); 76 MU_STREAM_READ);
77 mu_stream_unref (stream);
77 if (rc == 0) 78 if (rc == 0)
78 { 79 {
79 struct mu_pop3_stream *sp = (struct mu_pop3_stream *) stream; 80 struct mu_pop3_stream *sp = (struct mu_pop3_stream *) stream;
......
...@@ -580,7 +580,7 @@ lmtp_connection (int fd, struct sockaddr *sa, int salen, void *data, ...@@ -580,7 +580,7 @@ lmtp_connection (int fd, struct sockaddr *sa, int salen, void *data,
580 int rc; 580 int rc;
581 581
582 rc = mu_fd_stream_create (&str, NULL, fd, 582 rc = mu_fd_stream_create (&str, NULL, fd,
583 MU_STREAM_RDWR|MU_STREAM_AUTOCLOSE); 583 MU_STREAM_RDWR | MU_STREAM_FD_AUTOCLOSE);
584 if (rc) 584 if (rc)
585 { 585 {
586 mu_diag_funcall (MU_DIAG_ERROR, "mu_fd_stream_create", NULL, rc); 586 mu_diag_funcall (MU_DIAG_ERROR, "mu_fd_stream_create", NULL, rc);
......
...@@ -260,8 +260,11 @@ display_submessage (struct mime_descend_closure *closure, void *data) ...@@ -260,8 +260,11 @@ display_submessage (struct mime_descend_closure *closure, void *data)
260 /* Can we decode. */ 260 /* Can we decode. */
261 if (mu_filter_create (&d_stream, b_stream, closure->encoding, 261 if (mu_filter_create (&d_stream, b_stream, closure->encoding,
262 MU_FILTER_DECODE, 262 MU_FILTER_DECODE,
263 MU_STREAM_READ | MU_STREAM_AUTOCLOSE) == 0) 263 MU_STREAM_READ) == 0)
264 stream = d_stream; 264 {
265 mu_stream_unref (b_stream);
266 stream = d_stream;
267 }
265 else 268 else
266 stream = b_stream; 269 stream = b_stream;
267 270
......
...@@ -2498,13 +2498,13 @@ edit_mime (char *cmd, struct compose_env *env, mu_message_t *msg, int level) ...@@ -2498,13 +2498,13 @@ edit_mime (char *cmd, struct compose_env *env, mu_message_t *msg, int level)
2498 free (subtype); 2498 free (subtype);
2499 } 2499 }
2500 2500
2501 rc = mu_filter_create (&fstr, in, encoding, MU_FILTER_ENCODE, 2501 rc = mu_filter_create (&fstr, in, encoding, MU_FILTER_ENCODE, MU_STREAM_READ);
2502 MU_STREAM_READ | MU_STREAM_AUTOCLOSE);
2503 if (rc) 2502 if (rc)
2504 { 2503 {
2505 fstr = in; 2504 fstr = in;
2506 in = NULL; 2505 mu_stream_ref (in);
2507 } 2506 }
2507 mu_stream_unref (in);
2508 free (encoding); 2508 free (encoding);
2509 2509
2510 mu_message_get_body (*msg, &body); 2510 mu_message_get_body (*msg, &body);
......
...@@ -135,12 +135,12 @@ pop3d_setio (int ifd, int ofd) ...@@ -135,12 +135,12 @@ pop3d_setio (int ifd, int ofd)
135 pop3d_abquit (ERR_NO_OFILE); 135 pop3d_abquit (ERR_NO_OFILE);
136 136
137 if (mu_stdio_stream_create (&istream, ifd, 137 if (mu_stdio_stream_create (&istream, ifd,
138 MU_STREAM_READ | MU_STREAM_AUTOCLOSE)) 138 MU_STREAM_READ | MU_STREAM_FD_AUTOCLOSE))
139 pop3d_abquit (ERR_NO_IFILE); 139 pop3d_abquit (ERR_NO_IFILE);
140 mu_stream_set_buffer (istream, mu_buffer_line, 0); 140 mu_stream_set_buffer (istream, mu_buffer_line, 0);
141 141
142 if (mu_stdio_stream_create (&ostream, ofd, 142 if (mu_stdio_stream_create (&ostream, ofd,
143 MU_STREAM_WRITE | MU_STREAM_AUTOCLOSE)) 143 MU_STREAM_WRITE | MU_STREAM_FD_AUTOCLOSE))
144 pop3d_abquit (ERR_NO_OFILE); 144 pop3d_abquit (ERR_NO_OFILE);
145 145
146 /* Combine the two streams into an I/O one. */ 146 /* Combine the two streams into an I/O one. */
......