Commit d0a2801a d0a2801a8f77882ae959ec528607f9dc471552f8 by Sergey Poznyakoff

Cleanup in bufferization code.

* examples/musocio.c: Use default stream buffer size.
* imap4d/io.c: Likewise.
* libmailutils/dbgstream.c: Likewise.
* libmailutils/iostream.c: Likewise.
* libmailutils/xscript-stream.c: Likewise.
* libmu_auth/gsasl.c: Likewise.
* libmu_auth/tls.c: Likewise.
* libproto/pop/mbox.c: Likewise.
* libproto/pop/pop3_stream.c: Likewise.
* pop3d/extra.c: Likewise.

* libmailutils/file_stream.c (mu_file_stream_create)
(mu_fd_stream_create): File streams are fully buffered by default.
* libmailutils/stdio_stream.c (mu_stdio_stream_create): Stdio streams
are line buffered by default.
1 parent 98558025
......@@ -85,11 +85,11 @@ main (int argc, char * argv [])
}
MU_ASSERT (mu_stdio_stream_create (&in, MU_STDIN_FD, 0));
mu_stream_set_buffer (in, mu_buffer_line, 1024);
mu_stream_set_buffer (in, mu_buffer_line, 0);
MU_ASSERT (mu_stdio_stream_create (&out, MU_STDOUT_FD, 0));
mu_stream_set_buffer (out, mu_buffer_line, 1024);
mu_stream_set_buffer (out, mu_buffer_line, 0);
MU_ASSERT (mu_socket_stream_create (&sock, argv[1], MU_STREAM_RDWR));
mu_stream_set_buffer (sock, mu_buffer_line, 1024);
mu_stream_set_buffer (sock, mu_buffer_line, 0);
MU_ASSERT (mu_stream_open (sock));
pid = fork ();
......
......@@ -34,12 +34,13 @@ io_setio (FILE *in, FILE *out)
if (mu_stdio_stream_create (&istream, fileno (in),
MU_STREAM_READ | MU_STREAM_AUTOCLOSE))
imap4d_bye (ERR_STREAM_CREATE);
mu_stream_set_buffer (istream, mu_buffer_line, 1024);
mu_stream_set_buffer (istream, mu_buffer_line, 0);
if (mu_stdio_stream_create (&ostream, fileno (out),
MU_STREAM_WRITE | MU_STREAM_AUTOCLOSE))
imap4d_bye (ERR_STREAM_CREATE);
mu_stream_set_buffer (ostream, mu_buffer_line, 0);
/* Combine the two streams into an I/O one. */
if (mu_iostream_create (&str, istream, ostream))
imap4d_bye (ERR_STREAM_CREATE);
......@@ -51,7 +52,7 @@ io_setio (FILE *in, FILE *out)
MU_STREAM_WRITE | MU_STREAM_RDTHRU))
imap4d_bye (ERR_STREAM_CREATE);
/* Change buffering scheme: filter streams are fully buffered by default. */
mu_stream_set_buffer (iostream, mu_buffer_line, 1024);
mu_stream_set_buffer (iostream, mu_buffer_line, 0);
if (imap4d_transcript)
{
......
......@@ -79,7 +79,7 @@ mu_dbgstream_create(mu_stream_t *pref, mu_debug_t debug, mu_log_level_t level,
sp->debug = debug;
sp->level = level;
mu_stream_set_buffer ((mu_stream_t) sp, mu_buffer_line, 1024);
mu_stream_set_buffer ((mu_stream_t) sp, mu_buffer_line, 0);
*pref = (mu_stream_t) sp;
return 0;
}
......
......@@ -294,7 +294,10 @@ mu_file_stream_create (mu_stream_t *pstream, const char *filename, int flags)
filename, -1,
flags | MU_STREAM_SEEK | MU_STREAM_AUTOCLOSE);
if (rc == 0)
*pstream = (mu_stream_t) fstr;
{
*pstream = (mu_stream_t) fstr;
mu_stream_set_buffer ((mu_stream_t) fstr, mu_buffer_full, 0);
}
return rc;
}
......@@ -306,7 +309,10 @@ mu_fd_stream_create (mu_stream_t *pstream, char *filename, int fd, int flags)
sizeof (struct _mu_file_stream),
filename, fd, flags);
if (rc == 0)
*pstream = (mu_stream_t) fstr;
{
*pstream = (mu_stream_t) fstr;
mu_stream_set_buffer ((mu_stream_t) fstr, mu_buffer_full, 0);
}
return rc;
}
......
......@@ -253,7 +253,7 @@ mu_iostream_create (mu_stream_t *pref, mu_stream_t in, mu_stream_t out)
mu_stream_ref (out);
sp->transport[_MU_STREAM_OUTPUT] = out;
mu_stream_set_buffer ((mu_stream_t) sp, mu_buffer_line, 1024);
mu_stream_set_buffer ((mu_stream_t) sp, mu_buffer_line, 0);
*pref = (mu_stream_t) sp;
return 0;
}
......
......@@ -65,6 +65,7 @@ mu_stdio_stream_create (mu_stream_t *pstream, int fd, int flags)
return rc;
fstr->stream.open = NULL;
transport = (mu_stream_t) fstr;
mu_stream_set_buffer (transport, mu_buffer_line, 0);
/* Wrap it in cache, if required */
if (need_cache)
......
......@@ -435,7 +435,7 @@ mu_xscript_stream_create(mu_stream_t *pref, mu_stream_t transport,
free (sp);
return ENOMEM;
}
mu_stream_set_buffer ((mu_stream_t) sp, mu_buffer_line, 1024);
mu_stream_set_buffer ((mu_stream_t) sp, mu_buffer_line, 0);
*pref = (mu_stream_t) sp;
return 0;
}
......
......@@ -172,7 +172,7 @@ gsasl_encoder_stream (mu_stream_t *pstr, mu_stream_t transport,
_gsasl_encoder,
flt, flags);
if (rc == 0)
mu_stream_set_buffer (*pstr, mu_buffer_line, 1024);
mu_stream_set_buffer (*pstr, mu_buffer_line, 0);
return rc;
}
......@@ -188,7 +188,7 @@ gsasl_decoder_stream (mu_stream_t *pstr, mu_stream_t transport,
_gsasl_decoder,
flt, flags);
if (rc == 0)
mu_stream_set_buffer (*pstr, mu_buffer_line, 1024);
mu_stream_set_buffer (*pstr, mu_buffer_line, 0);
return rc;
}
......
......@@ -300,13 +300,13 @@ _mu_tls_io_stream_create (mu_stream_t *pstream,
{
sp->stream.read = _tls_io_read;
sp->stream.wait = _tls_rd_wait;
mu_stream_set_buffer ((mu_stream_t) sp, mu_buffer_full, 1024);
mu_stream_set_buffer ((mu_stream_t) sp, mu_buffer_full, 0);
}
else
{
sp->stream.write = _tls_io_write;
sp->stream.wait = _tls_wr_wait;
mu_stream_set_buffer ((mu_stream_t) sp, mu_buffer_line, 1024);
mu_stream_set_buffer ((mu_stream_t) sp, mu_buffer_line, 0);
}
sp->stream.flush = _tls_io_flush;
sp->stream.close = _tls_io_close;
......@@ -653,7 +653,7 @@ _mu_tls_stream_create (mu_stream_t *pstream,
return rc;
}
mu_stream_set_buffer ((mu_stream_t) sp, mu_buffer_line, 1024);
mu_stream_set_buffer ((mu_stream_t) sp, mu_buffer_line, 0);
*pstream = (mu_stream_t) sp;
return 0;
}
......
......@@ -149,7 +149,7 @@ pop_open (mu_mailbox_t mbox, int flags)
#endif /* WITH_TLS */
/* FIXME: How to configure buffer size? */
mu_stream_set_buffer (stream, mu_buffer_line, 1024);
mu_stream_set_buffer (stream, mu_buffer_line, 0);
status = mu_pop3_create (&mpd->pop3);
if (status)
......
......@@ -184,7 +184,7 @@ mu_pop3_stream_create (mu_pop3_t pop3, mu_stream_t *pstream)
sp->pop3 = pop3;
sp->flags = 0;
str = (mu_stream_t) sp;
mu_stream_set_buffer (str, mu_buffer_line, 1024);
mu_stream_set_buffer (str, mu_buffer_line, 0);
status = mu_pop3_filter_create (pstream, str);
mu_stream_unref (str);
......
......@@ -139,7 +139,7 @@ pop3d_setio (FILE *in, FILE *out)
if (mu_stdio_stream_create (&istream, fileno (in),
MU_STREAM_READ | MU_STREAM_AUTOCLOSE))
pop3d_abquit (ERR_NO_IFILE);
mu_stream_set_buffer (istream, mu_buffer_line, 1024);
mu_stream_set_buffer (istream, mu_buffer_line, 0);
if (mu_stdio_stream_create (&ostream, fileno (out),
MU_STREAM_WRITE | MU_STREAM_AUTOCLOSE))
......@@ -156,7 +156,7 @@ pop3d_setio (FILE *in, FILE *out)
MU_STREAM_WRITE | MU_STREAM_RDTHRU))
pop3d_abquit (ERR_NO_IFILE);
/* Change buffering scheme: filter streams are fully buffered by default. */
mu_stream_set_buffer (iostream, mu_buffer_line, 1024);
mu_stream_set_buffer (iostream, mu_buffer_line, 0);
if (pop3d_transcript)
{
......