Skip to content

Commit da65936

Browse files
committed
Minor refactoring
1 parent ea892f9 commit da65936

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed

data/txt/sha256sums.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ e3b8f8cf9607d12f3de5e6bcd5031f21f50d4b331844b8e921493dfde2efe0f7 lib/core/commo
169169
d53a8aecab8af8b8da4dc1c74d868f70a38770d34b1fa50cae4532cae7ce1c87 lib/core/compat.py
170170
ebe518089733722879f5a13e73020ebe55d46fb7410cacf292ca4ea1d9d1c56a lib/core/convert.py
171171
ae500647c4074681749735a4f3b17b7eca44868dd3f39f9cab0a575888ba04a1 lib/core/data.py
172-
a051955f483b281344ae16ecc1d26f77ea915db0a77a7b62c1a5b80feb2d4d87 lib/core/datatype.py
173-
da86858cc966861e0f28f8003a151c6b353dfecbdbbeadb73f38c618382b75c4 lib/core/decorators.py
172+
ffae7cfe9f9afb92e887b9a8dbc1630d0063e865f35984ae417b04a4513e5024 lib/core/datatype.py
173+
8a5a6f5313726d6880aeb1ffca35bc2ff6ecd3709b3e987551189a72fed25bf0 lib/core/decorators.py
174174
d573a37bb00c8b65f75b275aa92549683180fb209b75fd0ff3870e3848939900 lib/core/defaults.py
175175
ce6e1c1766acd95168f7708ddcacaa4a586c21ffc9e92024c4715611c802b60c lib/core/dicts.py
176176
c9d1f64648062d7962caf02c4e2e7d84e8feb2a14451146f627112aae889afcd lib/core/dump.py
@@ -187,7 +187,7 @@ c4bfb493a03caf84dd362aec7c248097841de804b7413d0e1ecb8a90c8550bc0 lib/core/readl
187187
d1bd70c1a55858495c727fbec91e30af267459c8f64d50fabf9e4ee2c007e920 lib/core/replication.py
188188
1d0f80b0193ac5204527bfab4bde1a7aee0f693fd008e86b4b29f606d1ef94f3 lib/core/revision.py
189189
d2eb8e4b05ac93551272b3d4abfaf5b9f2d3ac92499a7704c16ed0b4f200db38 lib/core/session.py
190-
a943ba4cf82c077d17bf250e7682ff8bc16ee0e67401fc520e1f6b9a79ba61d3 lib/core/settings.py
190+
a4f0bd3aec711d65a6a18dfb1b966c5890a93f3c1a47187831c0831fb0e89034 lib/core/settings.py
191191
1c5eab9494eb969bc9ce118a2ea6954690c6851cbe54c18373c723b99734bf09 lib/core/shell.py
192192
4eea6dcf023e41e3c64b210cb5c2efc7ca893b727f5e49d9c924f076bb224053 lib/core/subprocessng.py
193193
cdd352e1331c6b535e780f6edea79465cb55af53aa2114dcea0e8bf382e56d1a lib/core/target.py

lib/core/datatype.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,10 @@ def __contains__(self, key):
152152
return key in self.cache
153153

154154
def __getitem__(self, key):
155-
value = self.cache.pop(key)
156-
self.cache[key] = value
157-
return value
155+
with self.__lock:
156+
value = self.cache.pop(key)
157+
self.cache[key] = value
158+
return value
158159

159160
def get(self, key):
160161
return self.__getitem__(key)

lib/core/decorators.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from lib.core.threads import getCurrentThreadData
1616

1717
_cache = {}
18-
_cache_lock = threading.Lock()
18+
_method_locks = {}
1919

2020
def cachedmethod(f):
2121
"""
@@ -37,22 +37,27 @@ def cachedmethod(f):
3737
"""
3838

3939
_cache[f] = LRUDict(capacity=MAX_CACHE_ITEMS)
40+
_method_locks[f] = threading.RLock()
4041

4142
@functools.wraps(f)
4243
def _f(*args, **kwargs):
44+
parts = (
45+
f.__module__ + "." + f.__name__,
46+
"|".join(repr(a) for a in args),
47+
"|".join("%s=%r" % (k, kwargs[k]) for k in sorted(kwargs))
48+
)
4349
try:
44-
key = int(hashlib.md5("|".join(str(_) for _ in (f, args, kwargs)).encode(UNICODE_ENCODING)).hexdigest(), 16) & 0x7fffffffffffffff
50+
key = int(hashlib.md5("|".join(parts).encode(UNICODE_ENCODING)).hexdigest(), 16) & 0x7fffffffffffffff
4551
except ValueError: # https://github.com/sqlmapproject/sqlmap/issues/4281 (NOTE: non-standard Python behavior where hexdigest returns binary value)
4652
result = f(*args, **kwargs)
4753
else:
48-
try:
49-
with _cache_lock:
50-
result = _cache[f][key]
51-
except KeyError:
52-
result = f(*args, **kwargs)
53-
54-
with _cache_lock:
55-
_cache[f][key] = result
54+
lock, cache = _method_locks[f], _cache[f]
55+
with lock:
56+
try:
57+
result = cache[key]
58+
except KeyError:
59+
result = f(*args, **kwargs)
60+
cache[key] = result
5661

5762
return result
5863

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from thirdparty import six
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.9.7.1"
22+
VERSION = "1.9.7.2"
2323
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2424
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2525
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

0 commit comments

Comments
 (0)