From 6dd4f7648a91982c572f05866078e783e0ceda16 Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 10 Oct 2023 00:22:23 +0000 Subject: [PATCH] flush writes to clients before socket shutdown --- r0c/ivt100.py | 6 +----- r0c/util.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/r0c/ivt100.py b/r0c/ivt100.py index 9d62c47..ef1d9e1 100644 --- a/r0c/ivt100.py +++ b/r0c/ivt100.py @@ -191,11 +191,7 @@ class VT100_Server(object): with self.world.mutex: # Util.whoops("client part") - try: - remote.sck.shutdown(socket.SHUT_RDWR) - remote.sck.close() - except: - pass + Util.Daemon(Util.close_sck, "close_%s" % (remote.user.nick), (remote.sck,)) if announce: print( diff --git a/r0c/util.py b/r0c/util.py index 4767799..8dbe9b4 100644 --- a/r0c/util.py +++ b/r0c/util.py @@ -4,6 +4,7 @@ from .__init__ import EP, PY2, WINDOWS, COLORS, INTERP, unicode import traceback import threading +import socket import struct import time import sys @@ -635,6 +636,18 @@ def py26_threading_event_wait(event): event.wait = nice_meme +def close_sck(sck): + # could go fancy and grab the siocoutq stuff from copyparty but ehh + try: + sck.shutdown(socket.SHUT_WR) + time.sleep(0.1) + sck.shutdown(socket.SHUT_RDWR) + except: + pass + finally: + sck.close() + + """ # --------------------------------------------------------------------- # dumping ground for mostly useless code below