Skip to content

Commit

Permalink
up2k: fix put-hasher dying + a harmless race
Browse files Browse the repository at this point in the history
* hasher thread could die if a client would rapidly
   upload and delete files (so very unlikely)

* two unprotected calls to register_vpath which was
   almost-definitely safe because the volumes
   already existed in the registry
  • Loading branch information
9001 committed Apr 18, 2024
1 parent 08d8c82 commit feecb3e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions copyparty/up2k.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,9 @@ def init_indexes(
self.volstate[vol.vpath] = "online (mtp soon)"

for vol in need_vac:
reg = self.register_vpath(vol.realpath, vol.flags)
with self.mutex, self.reg_mutex:
reg = self.register_vpath(vol.realpath, vol.flags)

assert reg
cur, _ = reg
with self.mutex:
Expand All @@ -825,7 +827,9 @@ def init_indexes(
if vol.flags["dbd"] == "acid":
continue

reg = self.register_vpath(vol.realpath, vol.flags)
with self.mutex, self.reg_mutex:
reg = self.register_vpath(vol.realpath, vol.flags)

try:
assert reg
cur, db_path = reg
Expand Down Expand Up @@ -4251,7 +4255,7 @@ def _hasher(self) -> None:
raise Exception("invalid hash task")

try:
if not self._hash_t(task):
if not self._hash_t(task) and self.stop:
return
except Exception as ex:
self.log("failed to hash %s: %s" % (task, ex), 1)
Expand Down

0 comments on commit feecb3e

Please sign in to comment.