[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: Review Request: Do not terminate threads
From:       "Thiago Macieira" <thiago () kde ! org>
Date:       2011-08-11 11:11:29
Message-ID: 20110811111129.17229.7199 () vidsolbach ! de
[Download RAW message or body]

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/102179/#review5636
-----------------------------------------------------------



kio/kio/hostinfo.cpp
<http://git.reviewboard.kde.org/r/102179/#comment5046>

    This class could be simplified to a simple struct.



kio/kio/hostinfo.cpp
<http://git.reviewboard.kde.org/r/102179/#comment5047>

    This class isn't necessary. We can do the same with QThread alone.
    =

    To quit the thread, connect the worker's destroyed() signal to the thre=
ad's quit() slot. Then just deleteLater the worker.



kio/kio/hostinfo.cpp
<http://git.reviewboard.kde.org/r/102179/#comment5048>

    Remove the cache too. QHostInfo already caches.



kio/kio/hostinfo.cpp
<http://git.reviewboard.kde.org/r/102179/#comment5049>

    Huh? What is the acquire/release doing here?


- Thiago


On Aug. 11, 2011, 10:34 a.m., Albert Astals Cid wrote:
> =

> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/102179/
> -----------------------------------------------------------
> =

> (Updated Aug. 11, 2011, 10:34 a.m.)
> =

> =

> Review request for kdelibs and Dawit Alemayehu.
> =

> =

> Summary
> -------
> =

> Each time the terminate code triggers my Konqueror crashes, i'm substitut=
ing the terminate for just waiting the thread to finish and we just ignorin=
g it.
> =

> The code has a race condition in which wait() returns false, then we swit=
ch to the thread and m_autoDelete is still not set and thus noone will dele=
te the thread. I can add a mutex if you guys think this is unacceptable.
> =

> =

> Diffs
> -----
> =

>   kio/kio/hostinfo.cpp 344b1d8 =

> =

> Diff: http://git.reviewboard.kde.org/r/102179/diff
> =

> =

> Testing
> -------
> =

> When the =

> kDebug() << "Name look up for" << hostName << "failed";
> if triggers i do not get a crash anymore.
> =

> =

> Thanks,
> =

> Albert
> =

>


[Attachment #3 (text/html)]

<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/102179/">http://git.reviewboard.kde.org/r/102179/</a>
  </td>
    </tr>
   </table>
   <br />









<div>




<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/102179/diff/7/?file=31685#file31685line118" \
style="color: black; font-weight: bold; text-decoration: \
underline;">kio/kio/hostinfo.cpp</a>  <span style="font-weight: normal;">

     (Diff revision 7)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; \
">namespace KIO</pre></td>

  </tr>
 </tbody>



 
 




 <tbody>

  <tr>
    <th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2">116</font></th>  <td bgcolor="#fdfebc" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; ">    <span \
class="k">class</span> <span class="nc">NameLook<span \
class="hl">U</span>pThread</span><span class="hl"> </span><span class="o"><span \
class="hl">:</span></span><span class="hl"> </span><span class="k"><span \
class="hl">public</span></span><span class="hl"> </span><span class="n"><span \
class="hl">QThread</span></span></pre></td>  <th bgcolor="#e9eaa8" \
style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" \
align="right"><font size="2">118</font></th>  <td bgcolor="#fdfebc" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; ">    <span \
class="k">class</span> <span class="nc">NameLook<span class="hl">u</span>pThread<span \
class="hl">Petition</span></span></pre></td>  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This class \
could be simplified to a simple struct.</pre> </div>
<br />

<div>




<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/102179/diff/7/?file=31685#file31685line201" \
style="color: black; font-weight: bold; text-decoration: \
underline;">kio/kio/hostinfo.cpp</a>  <span style="font-weight: normal;">

     (Diff revision 7)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; \
">namespace KIO</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">195</font></th>  <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">    <span \
class="k">class</span> <span class="nc">NameLookUpThread</span> <span \
class="o">:</span> <span class="k">public</span> <span \
class="n">QThread</span></pre></td>  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This class \
isn&#39;t necessary. We can do the same with QThread alone.

To quit the thread, connect the worker&#39;s destroyed() signal to the thread&#39;s \
quit() slot. Then just deleteLater the worker.</pre> </div>
<br />

<div>




<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/102179/diff/7/?file=31685#file31685line264" \
style="color: black; font-weight: bold; text-decoration: \
underline;">kio/kio/hostinfo.cpp</a>  <span style="font-weight: normal;">

     (Diff revision 7)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; \
">namespace KIO</pre></td>

  </tr>
 </tbody>



 
 




 <tbody>

  <tr>
    <th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2">183</font></th>  <td bgcolor="#fdfebc" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; ">    <span class="c1">// Wait \
for it to start...</span></pre></td>  <th bgcolor="#e9eaa8" style="border-left: 1px \
solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font \
size="2">258</font></th>  <td bgcolor="#fdfebc" width="50%"><pre style="font-size: \
8pt; line-height: 140%; margin: 0; ">    <span class="c1">// Look up the name in the \
KIO/KHTML DNS cache...</span></pre></td>  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Remove the \
cache too. QHostInfo already caches.</pre> </div>
<br />

<div>




<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/102179/diff/7/?file=31685#file31685line272" \
style="color: black; font-weight: bold; text-decoration: \
underline;">kio/kio/hostinfo.cpp</a>  <span style="font-weight: normal;">

     (Diff revision 7)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; \
">namespace KIO</pre></td>

  </tr>
 </tbody>



 
 




 <tbody>

  <tr>
    <th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2">191</font></th>  <td bgcolor="#fdfebc" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span \
class="n">kDebug</span><span class="p">()</span> <span class="o">&lt;&lt;</span> \
<span class="s">&quot;Name look up for&quot;</span> <span class="o">&lt;&lt;</span> \
<span class="n">hostName</span> <span class="o">&lt;&lt;</span> <span \
class="s">&quot;failed&quot;</span><span class="p">;</span></pre></td>  <th \
bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">266</font></th>  <td bgcolor="#fdfebc" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">    <span \
class="n">nameLookUpThread</span><span class="o">-&gt;</span><span \
class="n">semaphore</span><span class="p">()</span><span class="o">-&gt;</span><span \
class="n">acquire</span><span class="p">();</span></pre></td>  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Huh? What \
is the acquire/release doing here?</pre> </div>
<br />



<p>- Thiago</p>


<br />
<p>On August 11th, 2011, 10:34 a.m., Albert Astals Cid 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 Dawit Alemayehu.</div>
<div>By Albert Astals Cid.</div>


<p style="color: grey;"><i>Updated Aug. 11, 2011, 10:34 a.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;">Each time the terminate code triggers my Konqueror crashes, i&#39;m \
substituting the terminate for just waiting the thread to finish and we just ignoring \
it.

The code has a race condition in which wait() returns false, then we switch to the \
thread and m_autoDelete is still not set and thus noone will delete the thread. I can \
add a mutex if you guys think this is unacceptable.</pre>  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </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;">When the  kDebug() &lt;&lt; &quot;Name look up for&quot; &lt;&lt; \
hostName &lt;&lt; &quot;failed&quot;; if triggers i do not get a crash anymore.</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>kio/kio/hostinfo.cpp <span style="color: grey">(344b1d8)</span></li>

</ul>

<p><a href="http://git.reviewboard.kde.org/r/102179/diff/" style="margin-left: \
3em;">View Diff</a></p>




  </td>
 </tr>
</table>








  </div>
 </body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic