Skip to content

Commit

Permalink
Fix race conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
andresriancho committed Apr 17, 2019
1 parent 685710e commit 09e7544
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions w3af/core/controllers/core_helpers/not_found/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ def __call__(self, *args, **kwargs):

url_cache_key = self.get_url_cache_key(http_response)

result = self._is_404_by_url_lru.get(url_cache_key, None)

try:
result = self._is_404_by_url_lru.get(url_cache_key, None)
except (AttributeError, AssertionError, KeyError) as _:
# This is a rare race conditions which happens when another
# thread modifies the cache and changes the __first item in
# the cache.
result = None

if result is not None:
self._log_success(http_response, result, 'URL')
return result
Expand Down
4 changes: 2 additions & 2 deletions w3af/core/data/misc/response_cache_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def get_response_cache_key(self,

try:
result = self._cache.get(cache_key, None)
except (AssertionError, KeyError) as _:
except (AttributeError, AssertionError, KeyError) as _:
# This is a rare race conditions which happens when another
# thread modifies the cache and changes the __first item in
# the cache.
Expand All @@ -165,7 +165,7 @@ def get_response_cache_key(self,

try:
self._cache[cache_key] = result
except (AssertionError, KeyError) as _:
except (AttributeError, AssertionError, KeyError) as _:
# This is a rare race conditions which happens when another
# thread modifies the cache and changes the __first item in
# the cache.
Expand Down

0 comments on commit 09e7544

Please sign in to comment.