bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2015-2018 Dovecot authors, see the included COPYING file */
ea623e25e8d03cb1c28677f418d3dcd5729d09e1Stephan Boscho_stream_unix_close(struct iostream_private *stream, bool close_parent)
ea623e25e8d03cb1c28677f418d3dcd5729d09e1Stephan Bosch struct unix_ostream *ustream = (struct unix_ostream *)stream;
ea623e25e8d03cb1c28677f418d3dcd5729d09e1Stephan Boschstatic ssize_t o_stream_unix_writev(struct file_ostream *fstream,
ea623e25e8d03cb1c28677f418d3dcd5729d09e1Stephan Bosch struct unix_ostream *ustream = (struct unix_ostream *)fstream;
ea623e25e8d03cb1c28677f418d3dcd5729d09e1Stephan Bosch return o_stream_file_writev(fstream, iov, iov_count);
ea623e25e8d03cb1c28677f418d3dcd5729d09e1Stephan Bosch /* send first iovec along with fd */
ea623e25e8d03cb1c28677f418d3dcd5729d09e1Stephan Bosch /* update stream */
ea623e25e8d03cb1c28677f418d3dcd5729d09e1Stephan Bosch if (sent < iov[0].iov_len || iov_count == 1) {
ea623e25e8d03cb1c28677f418d3dcd5729d09e1Stephan Bosch /* caller will call us again to write the rest */
ea623e25e8d03cb1c28677f418d3dcd5729d09e1Stephan Bosch /* send remaining iovecs */
ea623e25e8d03cb1c28677f418d3dcd5729d09e1Stephan Bosch ret = o_stream_file_writev(fstream, &iov[1], iov_count-1);
ea623e25e8d03cb1c28677f418d3dcd5729d09e1Stephan Bosch return (errno == EAGAIN || errno == EINTR ? (ssize_t)sent : ret);
ea623e25e8d03cb1c28677f418d3dcd5729d09e1Stephan Boschstruct ostream *o_stream_create_unix(int fd, size_t max_buffer_size)
ea623e25e8d03cb1c28677f418d3dcd5729d09e1Stephan Bosch output = o_stream_create_file_common(&ustream->fstream, fd,
ea623e25e8d03cb1c28677f418d3dcd5729d09e1Stephan Bosch output->real_stream->iostream.close = o_stream_unix_close;
ea623e25e8d03cb1c28677f418d3dcd5729d09e1Stephan Bosch ustream->fstream.writev = o_stream_unix_writev;