diff --git a/copyparty/util.py b/copyparty/util.py index cc8f01ee..b806e040 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -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() diff --git a/tests/util.py b/tests/util.py index 000244db..be158a72 100644 --- a/tests/util.py +++ b/tests/util.py @@ -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"