mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 01:22:13 -06:00
more socket cleanup fiddling
This commit is contained in:
parent
fac4b08526
commit
d2ae822e15
|
@ -1462,6 +1462,11 @@ else:
|
||||||
|
|
||||||
def shut_socket(log: "NamedLogger", sck: socket.socket, timeout: int = 3) -> None:
|
def shut_socket(log: "NamedLogger", sck: socket.socket, timeout: int = 3) -> None:
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
|
fd = sck.fileno()
|
||||||
|
if fd == -1:
|
||||||
|
sck.close()
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sck.settimeout(timeout)
|
sck.settimeout(timeout)
|
||||||
sck.shutdown(socket.SHUT_WR)
|
sck.shutdown(socket.SHUT_WR)
|
||||||
|
@ -1474,12 +1479,14 @@ def shut_socket(log: "NamedLogger", sck: socket.socket, timeout: int = 3) -> Non
|
||||||
# on windows in particular, drain rx until client shuts
|
# on windows in particular, drain rx until client shuts
|
||||||
if not sck.recv(32 * 1024):
|
if not sck.recv(32 * 1024):
|
||||||
break
|
break
|
||||||
|
|
||||||
|
sck.shutdown(socket.SHUT_RDWR)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
td = time.time() - t0
|
td = time.time() - t0
|
||||||
if td >= 1:
|
if td >= 1:
|
||||||
log("shut() in {:.3f} sec".format(td), "1;30")
|
log("shut({}) in {:.3f} sec".format(fd, td), "1;30")
|
||||||
|
|
||||||
sck.close()
|
sck.close()
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ class Cfg(Namespace):
|
||||||
ex = "no_rescan no_sendfile no_voldump"
|
ex = "no_rescan no_sendfile no_voldump"
|
||||||
ka.update(**{k: True for k in ex.split()})
|
ka.update(**{k: True for k in ex.split()})
|
||||||
|
|
||||||
ex = "css_browser hist js_browser no_hash no_idx"
|
ex = "css_browser hist js_browser no_hash no_idx no_forget"
|
||||||
ka.update(**{k: None for k in ex.split()})
|
ka.update(**{k: None for k in ex.split()})
|
||||||
|
|
||||||
ex = "re_maxage rproxy rsp_slp s_wr_slp theme themes turbo df"
|
ex = "re_maxage rproxy rsp_slp s_wr_slp theme themes turbo df"
|
||||||
|
|
Loading…
Reference in a new issue