Optimize I/O bufferization.
New ioctls MU_IOCTL_GET_TRANSPORT_BUFFER and MU_IOCTL_SET_TRANSPORT_BUFFER return and modify bufferization mode in the lowest level transport stream. Both server and client programs use this to switch to full buffering before sending large amounts of data. This has a particular impact on the output speed and CPU usage when TLS is in use. * include/mailutils/stream.h (MU_IOCTL_GET_TRANSPORT_BUFFER) (MU_IOCTL_SET_TRANSPORT_BUFFER): New ioctls. (MU_TRANSPORT_INPUT, MU_TRANSPORT_OUTPUT): New constants. (MU_TRANSPORT_VALID_TYPE): New macro. (mu_buffer_query): New struct. (mu_stream_get_buffer): New proto. * libmu_auth/tls.c (_tls_io_ioctl): Return ENOSYS if op is not supported. (_tls_ioctl): Support MU_IOCTL_[GS]ET_TRANSPORT_BUFFER. * mailbox/file_stream.c (fd_ioctl): Support MU_IOCTL_[GS]ET_TRANSPORT_BUFFER. Return ENOSYS if op is not supported. * mailbox/filter_iconv.c (_icvt_ioctl): Likewise. * mailbox/iostream.c (_iostream_ctl): Likewise. * mailbox/mapfile_stream.c (_mapfile_ioctl): Likewise. * mailbox/memory_stream.c (_memory_ioctl): Likewise. * mailbox/rdcache_stream.c (rdcache_ioctl): Likewise. * mailbox/xscript-stream.c (_xscript_ctl): Likewise. * mailbox/prog_stream.c (_prog_ioctl): Return ENOSYS if op is not supported. * mailbox/tcp.c (_tcp_ioctl): Likewise. * mailbox/stream.c (mu_stream_default_buffer_size): New global. (mu_stream_seek): Do not call seek method if the requested offset is the same as the current one. (mu_stream_set_buffer): Size==0 means use the default value. (mu_stream_get_buffer): New function. (mu_stream_truncate): Flush the buffer before truncating. * mailbox/mime.c (mime_reset_state): New function. (_mime_body_stream_seek): Rewrite using mime_reset_state. (_mime_body_stream_ioctl): Return ENOSYS if op is not supported. (create_mime_body_stream): Reset mime state (_mime_body_stream_seek may not be called due to the optimization in mu_stream_seek. * mailbox/header.c (header_parse): Exit correctly if the buffer is not terminated with a \n. * libproto/mbox/mbox.c (mbox_open): Enforce full buffering on the mailbox stream. * libproto/pop/mbox.c (pop_header_fill): Minor fix. * libproto/pop/pop3_stream.c (_POP3F_DONE) (_POP3F_CHBUF): New constants. (mu_pop3_stream)<done>: Remove. Replaced with flags. <oldbuf>: New member. (_pop3_event_cb): If _POP3F_CHBUF flag is set, restore the initial buffering mode on the transport stream. (mu_pop3_filter_create): Save away current buffering mode and enforce full buffering while transferring bulk data. * mail/from.c (hdr_from): Check return value from mu_message_get_header. * mail/mail.c (main): Allow for MAILRC having empty value. Always close the mailbox before exiting. * pop3d/pop3d.c (pop3d_cfg_param): New statement output-buffer-size. * pop3d/pop3d.h (pop3d_output_bufsize): New global. * pop3d/retr.c (pop3d_send_payload): New function. (pop3d_retr): Rewrite using pop3d_send_payload. Save away current buffering mode and enforce full buffering while transferring bulk data. * pop3d/top.c (pop3d_top_: Likewise.
Showing
23 changed files
with
289 additions
and
63 deletions
-
Please register or sign in to post a comment