Commit eeea1bbd authored by Wayne Davison's avatar Wayne Davison

Improved some I/O comments.

parent aa3999d6
...@@ -489,23 +489,25 @@ void restore_iobuf_size(xbuf *out) ...@@ -489,23 +489,25 @@ void restore_iobuf_size(xbuf *out)
} }
} }
/* Perform buffered input and output until specified conditions are met. When /* Perform buffered input and/or output until specified conditions are met.
* given a "needed" read requirement, we'll return without doing any I/O if the * When given a "needed" read or write request, this returns without doing any
* iobuf.in bytes are already available. When reading, we'll read as many * I/O if the needed input bytes or write space is already available. Once I/O
* bytes as we can into the buffer, and return as soon as we meet the minimum * is needed, this will try to do whatever reading and/or writing is currently
* read requirement. When given a "needed" write requirement, we'll return * possible, up to the maximum buffer allowances, no matter if this is a read
* without doing any I/O if that many bytes will fit in the output buffer (we * or write request. However, the I/O stops as soon as the required input
* check either iobuf.out or iobuf.msg, depending on the flags). When writing, * bytes or output space is available. If this is not a read request, the
* we write out as much as we can, and return as soon as the given free-space * routine may also do some advantageous reading of messages from a multiplexed
* requirement is available. * input source (which ensures that we don't jam up with everyone in their
* "need to write" code and nobody reading the accumulated data that would make
* writing possible).
* *
* The iobuf.out and iobuf.msg buffers are circular, so some writes into them * The iobuf.in, .out and .msg buffers are all circular. Callers need to be
* will need to be split when the data needs to wrap around to the start. In * aware that some data copies will need to be split when the bytes wrap around
* order to help make this easier for some operations (such as the use of * from the end to the start. In order to help make writing into the output
* SIVAL() into the buffer) a buffer may be temporarily shortened, but the * buffers easier for some operations (such as the use of SIVAL() into the
* original size will be automatically restored. The iobuf.in buffer is also * buffer) a buffer may be temporarily shortened by a small amount, but the
* circular, so callers may need to split their reading of the data if it spans * original size will be automatically restored when the .pos wraps to the
* the end. See also the 3 raw_* iobuf vars that are used in the handling of * start. See also the 3 raw_* iobuf vars that are used in the handling of
* MSG_DATA bytes as they are read-from/written-into the buffers. * MSG_DATA bytes as they are read-from/written-into the buffers.
* *
* When writing, we flush data in the following priority order: * When writing, we flush data in the following priority order:
...@@ -1370,7 +1372,7 @@ static void read_a_msg(void) ...@@ -1370,7 +1372,7 @@ static void read_a_msg(void)
* the buffer the msg data will end once it is read. It is * the buffer the msg data will end once it is read. It is
* possible that this points off the end of the buffer, in * possible that this points off the end of the buffer, in
* which case the gradual reading of the input stream will * which case the gradual reading of the input stream will
* cause this value to decrease and eventually become real. */ * cause this value to wrap around and eventually become real. */
if (msg_bytes) if (msg_bytes)
iobuf.raw_input_ends_before = iobuf.in.pos + msg_bytes; iobuf.raw_input_ends_before = iobuf.in.pos + msg_bytes;
iobuf.in_multiplexed = 1; iobuf.in_multiplexed = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment