mirror of
https://github.com/9001/copyparty.git
synced 2026-04-12 15:22:32 -06:00
forget_ip: fix cursor locking
This commit is contained in:
parent
753ff548f2
commit
37123e33d2
|
|
@ -661,19 +661,20 @@ class Up2k(object):
|
||||||
|
|
||||||
for _ in range(2):
|
for _ in range(2):
|
||||||
q = "select ip, at from up where ip > '' order by +at limit 1"
|
q = "select ip, at from up where ip > '' order by +at limit 1"
|
||||||
hits = cur.execute(q).fetchall()
|
with self.mutex:
|
||||||
if not hits:
|
hits = cur.execute(q).fetchall()
|
||||||
break
|
if not hits:
|
||||||
|
break
|
||||||
|
|
||||||
remains = hits[0][1] - cutoff
|
remains = hits[0][1] - cutoff
|
||||||
if remains > 0:
|
if remains > 0:
|
||||||
timeout = min(timeout, now + remains)
|
timeout = min(timeout, now + remains)
|
||||||
break
|
break
|
||||||
|
|
||||||
q = "update up set ip = '' where ip > '' and at <= %d"
|
q = "update up set ip = '' where ip > '' and at <= %d"
|
||||||
cur.execute(q % (cutoff,))
|
cur.execute(q % (cutoff,))
|
||||||
zi = cur.rowcount
|
zi = cur.rowcount
|
||||||
cur.connection.commit()
|
cur.connection.commit()
|
||||||
|
|
||||||
t = "forget-ip(%d) removed %d IPs from db [/%s]"
|
t = "forget-ip(%d) removed %d IPs from db [/%s]"
|
||||||
self.log(t % (maxage, zi, vol.vpath))
|
self.log(t % (maxage, zi, vol.vpath))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue