Commit 8e262d87 8e262d87a226fbdf46af300836d4add807021de6 by Sergey Poznyakoff

Fixed some comments.

1 parent 71da3446
...@@ -38,13 +38,13 @@ ...@@ -38,13 +38,13 @@
38 38
39 static int refill (stream_t, off_t); 39 static int refill (stream_t, off_t);
40 40
41 /* Stream is a way for object to do I/O, they can take over(overload) the 41 /* A stream provides a way for an object to do I/O. It overloads
42 the read/write functions for there needs. We are doing some very 42 stream read/write functions. Only a minimal buffering is done
43 minimal buffering on the read when the stream_bufsiz is set, this 43 and that if stream's bufsiz member is set. If the requested
44 unfortunately does not take to account the offset i.e if the offset ask 44 offset does not equal the one maintained internally the buffer
45 is different then the offset we maintain internally, the buffer is flushed 45 is flushed and refilled. This buffering scheme is more convenient
46 and a new buffer is use, this buffering is more 46 for networking streams (POP/IMAP).
47 for networking stream (POP/IMAP). No buffering on the write. */ 47 Writes are always unbuffered. */
48 int 48 int
49 stream_create (stream_t *pstream, int flags, void *owner) 49 stream_create (stream_t *pstream, int flags, void *owner)
50 { 50 {
...@@ -56,8 +56,8 @@ stream_create (stream_t *pstream, int flags, void *owner) ...@@ -56,8 +56,8 @@ stream_create (stream_t *pstream, int flags, void *owner)
56 return ENOMEM; 56 return ENOMEM;
57 stream->owner = owner; 57 stream->owner = owner;
58 stream->flags = flags; 58 stream->flags = flags;
59 /* By default unbuffered, the buffered scheme is not for all models, it 59 /* By default unbuffered, the buffering scheme is not for all models, it
60 really makes sense for networking streams, where there is no offset. */ 60 really makes sense for network streams, where there is no offset. */
61 /* stream->rbuffer.bufsiz = BUFSIZ; */ 61 /* stream->rbuffer.bufsiz = BUFSIZ; */
62 *pstream = stream; 62 *pstream = stream;
63 return 0; 63 return 0;
...@@ -133,13 +133,12 @@ stream_setbufsiz (stream_t stream, size_t size) ...@@ -133,13 +133,12 @@ stream_setbufsiz (stream_t stream, size_t size)
133 } 133 }
134 134
135 /* We have to be clear about the buffering scheme, it is not designed to be 135 /* We have to be clear about the buffering scheme, it is not designed to be
136 use as a fully fledge buffer mechanism. It is a simple mechanims for 136 used as a full-fledged buffer mechanism. It is a simple mechanism for
137 networking. Lots of code between POP and IMAP can be share this way. 137 networking. Lots of code between POP and IMAP can be shared this way.
138 - First caveat; the offset as no meaning i.e. the code does move back or 138 - First caveat; the code maintains its own offset (rbuffer.offset member)
139 up the buffer, if the offset is different then the maintain interanl offset 139 and if it does not match the requested one, the data is flushed
140 the buffer is flush out and new read from the asking offset is done. It 140 and the underlying _read is called. It is up to the latter to return
141 is up to the concrete _read() to return EISPIPE when error. 141 EISPIPE when appropriate.
142
143 - Again, this is targeting networking stream to make readline() 142 - Again, this is targeting networking stream to make readline()
144 a little bit more efficient, instead of reading a char at a time. */ 143 a little bit more efficient, instead of reading a char at a time. */
145 144
...@@ -170,7 +169,7 @@ stream_read (stream_t is, char *buf, size_t count, ...@@ -170,7 +169,7 @@ stream_read (stream_t is, char *buf, size_t count,
170 size_t residue = count; 169 size_t residue = count;
171 int r; 170 int r;
172 171
173 /* If the amount requested is bigger then the buffer cache size 172 /* If the amount requested is bigger than the buffer cache size,
174 bypass it. Do no waste time and let it through. */ 173 bypass it. Do no waste time and let it through. */
175 if (count > is->rbuffer.bufsiz) 174 if (count > is->rbuffer.bufsiz)
176 { 175 {
......