<br><br><div class="gmail_quote">On Tue, Apr 15, 2008 at 12:19 AM, Curt Hagenlocher <<a href="mailto:curt@hagenlocher.org">curt@hagenlocher.org</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Mon, Apr 14, 2008 at 2:29 PM, Ralf Schmitt <<a href="mailto:schmir@gmail.com">schmir@gmail.com</a>> wrote:<br>
><br>
> Sorry to reply on the mailing list. But this change is wrong.<br>
> e.g. if you're using a buffer size of 16 bytes and try to read 256 bytes, it<br>
> should call recv with a value of 256 and not call recv 16 times with a value<br>
> of 16.<br>
> However, there should be an upper limit (as shown by the imap bug).<br>
<br>
</div>There is an upper limit. It's called "the buffer size". If someone<br>
specifies a buffer size of 16 bytes, it means "read 16 bytes at a<br>
time". I don't know why someone would want such a small buffer size,<br>
but presumably they have their reasons.<br>
</blockquote><div><br>No, I don't agree. To me buffer size means buffer up to buffer_size bytes in memory.<br>It does not mean that it should read only buffer_size bytes at once when asked to read more bytes than buffer size.<br>
<br> The upper limit I was talking about is the buffer size limit of the operating system, i.e. the operating system will at a maximum return N bytes from recv call. It doesn't make sense to ask for more then, and the original problem with imaplip asking for 10MB of data and then realloc'ing that buffer would be gone.<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
The only reason "min" is a problem is that there's standard library<br>
code passing a zero to socket.makefile, which gets turned into a<br>
bufsize of 1 by the constructor. I actually agree with Bill Janssen<br>
-- __init__ is where the real problem lies. But I think the change to<br>
read() is safer.<br>
<font color="#888888"></font></blockquote><div><br>again no, if I pass in 4 as buffer size, I don't expect the system to make 1024 calls to recv when I want to read 4096 bytes.<br><br>Regards,<br>- Ralf<br><br></div>
</div>