[bitbake-devel] fetch2: Fix urldata_cache key issues

Submitted by Richard Purdie on March 27, 2020, 2:48 p.m. | Patch ID: 171370

Details

Message ID 20200327144825.562857-1-richard.purdie@linuxfoundation.org
State Master Next
Commit 9acbce05a8a13257df594df8701949e7c2071759
Headers show

Commit Message

Richard Purdie March 27, 2020, 2:48 p.m.
Upon inspection its clear the way the keys for this cache were being handled
would break it and cause the cache to never be used. Fix this.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/fetch2/__init__.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index d8ad19b59b..813f5eb773 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -1631,8 +1631,11 @@  class Fetch(object):
 
         fn = d.getVar('FILE')
         mc = d.getVar('__BBMULTICONFIG') or ""
-        if cache and fn and mc + fn in urldata_cache:
-            self.ud = urldata_cache[mc + fn + str(id(d))]
+        key = None
+        if cache and fn:
+            key = mc + fn in urldata_cache
+        if key in urldata_cache:
+            self.ud = urldata_cache[key]
 
         for url in urls:
             if url not in self.ud:
@@ -1643,8 +1646,8 @@  class Fetch(object):
                         self.ud[url] = None
                         pass
 
-        if fn and cache:
-            urldata_cache[mc + fn + str(id(d))] = self.ud
+        if key:
+            urldata_cache[key] = self.ud
 
     def localpath(self, url):
         if url not in self.urls:

Comments

Matt Madison March 29, 2020, 12:21 p.m.
On Fri, Mar 27, 2020 at 7:48 AM Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
>
> Upon inspection its clear the way the keys for this cache were being handled
> would break it and cause the cache to never be used. Fix this.
>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  lib/bb/fetch2/__init__.py | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
> index d8ad19b59b..813f5eb773 100644
> --- a/lib/bb/fetch2/__init__.py
> +++ b/lib/bb/fetch2/__init__.py
> @@ -1631,8 +1631,11 @@ class Fetch(object):
>
>          fn = d.getVar('FILE')
>          mc = d.getVar('__BBMULTICONFIG') or ""
> -        if cache and fn and mc + fn in urldata_cache:
> -            self.ud = urldata_cache[mc + fn + str(id(d))]
> +        key = None
> +        if cache and fn:
> +            key = mc + fn in urldata_cache
This doesn't look right.  Did you really mean to have the 'in
urldata_cache' here?

-Matt

> +        if key in urldata_cache:
> +            self.ud = urldata_cache[key]
>
>          for url in urls:
>              if url not in self.ud:
> @@ -1643,8 +1646,8 @@ class Fetch(object):
>                          self.ud[url] = None
>                          pass
>
> -        if fn and cache:
> -            urldata_cache[mc + fn + str(id(d))] = self.ud
> +        if key:
> +            urldata_cache[key] = self.ud
>
>      def localpath(self, url):
>          if url not in self.urls:
> --
> 2.25.1
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#11224): https://lists.openembedded.org/g/bitbake-devel/message/11224
Mute This Topic: https://lists.openembedded.org/mt/72588822/3617530
Group Owner: bitbake-devel+owner@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub  [oe-patchwork@oe-patch.openembedded.org]
-=-=-=-=-=-=-=-=-=-=-=-
Richard Purdie March 29, 2020, 9:43 p.m.
On Sun, 2020-03-29 at 05:21 -0700, Matt Madison wrote:
> On Fri, Mar 27, 2020 at 7:48 AM Richard Purdie
> <richard.purdie@linuxfoundation.org> wrote:
> > Upon inspection its clear the way the keys for this cache were
> > being handled
> > would break it and cause the cache to never be used. Fix this.
> > 
> > Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> > ---
> >  lib/bb/fetch2/__init__.py | 11 +++++++----
> >  1 file changed, 7 insertions(+), 4 deletions(-)
> > 
> > diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
> > index d8ad19b59b..813f5eb773 100644
> > --- a/lib/bb/fetch2/__init__.py
> > +++ b/lib/bb/fetch2/__init__.py
> > @@ -1631,8 +1631,11 @@ class Fetch(object):
> > 
> >          fn = d.getVar('FILE')
> >          mc = d.getVar('__BBMULTICONFIG') or ""
> > -        if cache and fn and mc + fn in urldata_cache:
> > -            self.ud = urldata_cache[mc + fn + str(id(d))]
> > +        key = None
> > +        if cache and fn:
> > +            key = mc + fn in urldata_cache
> This doesn't look right.  Did you really mean to have the 'in
> urldata_cache' here?

No! Well spotted, thanks. I've fixed the patch.

Cheers,

Richard
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#11225): https://lists.openembedded.org/g/bitbake-devel/message/11225
Mute This Topic: https://lists.openembedded.org/mt/72588822/3617530
Group Owner: bitbake-devel+owner@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub  [oe-patchwork@oe-patch.openembedded.org]
-=-=-=-=-=-=-=-=-=-=-=-