more socket cleanup fiddling

This commit is contained in:
ed 2022-09-07 23:06:12 +02:00
parent fac4b08526
commit d2ae822e15
2 changed files with 9 additions and 2 deletions

View file

@ -1462,6 +1462,11 @@ else:
def shut_socket(log: "NamedLogger", sck: socket.socket, timeout: int = 3) -> None:
t0 = time.time()
fd = sck.fileno()
if fd == -1:
sck.close()
return
try:
sck.settimeout(timeout)
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
if not sck.recv(32 * 1024):
break
sck.shutdown(socket.SHUT_RDWR)
except:
pass
finally:
td = time.time() - t0
if td >= 1:
log("shut() in {:.3f} sec".format(td), "1;30")
log("shut({}) in {:.3f} sec".format(fd, td), "1;30")
sck.close()

View file

@ -100,7 +100,7 @@ class Cfg(Namespace):
ex = "no_rescan no_sendfile no_voldump"
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()})
ex = "re_maxage rproxy rsp_slp s_wr_slp theme themes turbo df"