<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="http://git.reviewboard.kde.org/r/101149/">http://git.reviewboard.kde.org/r/101149/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On April 18th, 2011, 8:31 p.m., <b>David Faure</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="http://git.reviewboard.kde.org/r/101149/diff/3/?file=14732#file14732line2405" style="color: black; font-weight: bold; text-decoration: underline;">kioslave/ftp/ftp.cpp</a>
<span style="font-weight: normal;">
(Diff revision 3)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">Ftp::StatusCode Ftp::ftpSendMimeType(int& iError, const KUrl& url)</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">2391</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="kt">int</span> <span class="n">bytesLeft</span> <span class="o">=</span> <span class="p">((</span><span class="n">m_size</span> <span class="o">==</span> <span class="n">UnknownSize</span> <span class="o">||</span> <span class="n">m_size</span> <span class="o">></span> <span class="mi">1024</span><span class="p">)</span> <span class="o">?</span> <span class="mi">1024</span> <span class="o">:</span> <span class="n">m_size</span><span class="p">);</span></pre></td>
</tr>
</tbody>
</table>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">If m_size is UnknownSize and the file is less than 1024 bytes, this code is going to hit the timeout, waiting for data to come in, that will never come in.
I think that once waitForReadyRead was called once, the loop should break (after peeking, of course), if m_size==Unknown.</pre>
</blockquote>
<p>On April 18th, 2011, 9:07 p.m., <b>Dawit Alemayehu</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">That won't happen because we also check the returned size of peek:
if (bytesRead == 0 || bytesLeft == 0) {
break;
}
so if the file size is < 1024, but m_size is unknown then the entire file the loop will break once it reads the entire file from buffer. I already tested that this works with our trusty README file of 404 bytes from the KDE ftp site.</pre>
</blockquote>
<p>On April 18th, 2011, 9:23 p.m., <b>David Faure</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Sorry, I don't get it. m_size=1024 (because unknown), real file size=404, bytesRead=404, bytesLeft=620 -> no break -> we go to "waitForReadyRead" until timeout.</pre>
</blockquote>
<p>On April 18th, 2011, 9:35 p.m., <b>Dawit Alemayehu</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">See new patch. I now handle that case too ; so you won't get the extra timeout condition. If bytesRead == totalSize (which is really the size we want), the it will break. Sorry about misreading your response. I thought you said it will be in an infinite loop. :)</pre>
</blockquote>
</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Nope, if m_size is UnknownSize, then we don't know the size we want. 1024 might be impossible to ever reach.
The new code makes sense, except in the case where m_size == UnknownSize. In that case, you need to break at the bottom of the while loop, I don't see another solution.</pre>
<br />
<p>- David</p>
<br />
<p>On April 18th, 2011, 9:28 p.m., Dawit Alemayehu wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('http://git.reviewboard.kde.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for kdelibs and David Faure.</div>
<div>By Dawit Alemayehu.</div>
<p style="color: grey;"><i>Updated April 18, 2011, 9:28 p.m.</i></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">The attached patch changes the ftpGet function such that it emits the mime-type of the content it is about to read, before starting to read it. That way kio_ftp will work correctly if and when it is put on hold to be reused from another application. Note that the patch uses QIODevice::peek to achieve this goal.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>kioslave/ftp/ftp.h <span style="color: grey">(9814c10)</span></li>
<li>kioslave/ftp/ftp.cpp <span style="color: grey">(64f43d8)</span></li>
</ul>
<p><a href="http://git.reviewboard.kde.org/r/101149/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>