<div dir="ltr">Wrong list, sorry.<div><br></div><div>Ross</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 25 July 2017 at 11:17, Ross Burton <span dir="ltr">&lt;<a href="mailto:ross.burton@intel.com" target="_blank">ross.burton@intel.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">When wget is fetching a listing for a directory over FTP it writes to a<br>
temporary file called .listing in the current directory.  If there are many such<br>
operations happening in parallel - for example during &#39;bitbake world -c<br>
checkpkg&#39; - then up to BB_NUMBER_THREADS instances of wget will be racing to<br>
write to, read, and delete the same file.<br>
<br>
This results in various failures such as the file disappearing before wget has<br>
processed it or the file changing contents, which causes checkpkg to randomly<br>
fail.<br>
<br>
Mitigate the race condition by creating a temporary directory to run wget in<br>
when doing directory listings.<br>
<br>
[ YOCTO #11828 ]<br>
<br>
Signed-off-by: Ross Burton &lt;<a href="mailto:ross.burton@intel.com">ross.burton@intel.com</a>&gt;<br>
---<br>
 bitbake/lib/bb/fetch2/wget.py | 23 +++++++++++------------<br>
 1 file changed, 11 insertions(+), 12 deletions(-)<br>
<br>
diff --git a/bitbake/lib/bb/fetch2/wget.<wbr>py b/bitbake/lib/bb/fetch2/wget.<wbr>py<br>
index 208ee9bdd69..8ee9769d39b 100644<br>
--- a/bitbake/lib/bb/fetch2/wget.<wbr>py<br>
+++ b/bitbake/lib/bb/fetch2/wget.<wbr>py<br>
@@ -90,13 +90,13 @@ class Wget(FetchMethod):<br>
<br>
         self.basecmd = d.getVar(&quot;FETCHCMD_wget&quot;) or &quot;/usr/bin/env wget -t 2 -T 30 --passive-ftp --no-check-certificate&quot;<br>
<br>
-    def _runwget(self, ud, d, command, quiet):<br>
+    def _runwget(self, ud, d, command, quiet, workdir=None):<br>
<br>
         progresshandler = WgetProgressHandler(d)<br>
<br>
         logger.debug(2, &quot;Fetching %s using command &#39;%s&#39;&quot; % (ud.url, command))<br>
         bb.fetch2.check_network_<wbr>access(d, command, ud.url)<br>
-        runfetchcmd(command + &#39; --progress=dot -v&#39;, d, quiet, log=progresshandler)<br>
+        runfetchcmd(command + &#39; --progress=dot -v&#39;, d, quiet, log=progresshandler, workdir=workdir)<br>
<br>
     def download(self, ud, d):<br>
         &quot;&quot;&quot;Fetch urls&quot;&quot;&quot;<br>
@@ -422,17 +422,16 @@ class Wget(FetchMethod):<br>
         Run fetch checkstatus to get directory information<br>
         &quot;&quot;&quot;<br>
         f = tempfile.NamedTemporaryFile()<br>
+        with tempfile.TemporaryDirectory(<wbr>prefix=&quot;wget-index-&quot;) as workdir, tempfile.NamedTemporaryFile(<wbr>dir=workdir, prefix=&quot;wget-listing-&quot;) as f:<br>
+            agent = &quot;Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101027 Ubuntu/9.10 (karmic) Firefox/3.6.12&quot;<br>
+            fetchcmd = self.basecmd<br>
+            fetchcmd += &quot; -O &quot; + <a href="http://f.name" rel="noreferrer" target="_blank">f.name</a> + &quot; --user-agent=&#39;&quot; + agent + &quot;&#39; &#39;&quot; + uri + &quot;&#39;&quot;<br>
+            try:<br>
+                self._runwget(ud, d, fetchcmd, True, workdir=workdir)<br>
+                fetchresult = f.read()<br>
+            except bb.fetch2.BBFetchException:<br>
+                fetchresult = &quot;&quot;<br>
<br>
-        agent = &quot;Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101027 Ubuntu/9.10 (karmic) Firefox/3.6.12&quot;<br>
-        fetchcmd = self.basecmd<br>
-        fetchcmd += &quot; -O &quot; + <a href="http://f.name" rel="noreferrer" target="_blank">f.name</a> + &quot; --user-agent=&#39;&quot; + agent + &quot;&#39; &#39;&quot; + uri + &quot;&#39;&quot;<br>
-        try:<br>
-            self._runwget(ud, d, fetchcmd, True)<br>
-            fetchresult = f.read()<br>
-        except bb.fetch2.BBFetchException:<br>
-            fetchresult = &quot;&quot;<br>
-<br>
-        f.close()<br>
         return fetchresult<br>
<br>
     def _check_latest_version(self, url, package, package_regex, current_version, ud, d):<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.11.0<br>
<br>
</font></span></blockquote></div><br></div>