mirror of https://github.com/fail2ban/fail2ban
Merge branch '0.10' into 0.11
commit
a92f25b48e
|
@ -43,7 +43,7 @@ class CSocket:
|
||||||
self.__csock.connect(sock)
|
self.__csock.connect(sock)
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
self.close(False)
|
self.close()
|
||||||
|
|
||||||
def send(self, msg, nonblocking=False, timeout=None):
|
def send(self, msg, nonblocking=False, timeout=None):
|
||||||
# Convert every list member to string
|
# Convert every list member to string
|
||||||
|
@ -56,13 +56,18 @@ class CSocket:
|
||||||
def settimeout(self, timeout):
|
def settimeout(self, timeout):
|
||||||
self.__csock.settimeout(timeout if timeout != -1 else self.__deftout)
|
self.__csock.settimeout(timeout if timeout != -1 else self.__deftout)
|
||||||
|
|
||||||
def close(self, sendEnd=True):
|
def close(self):
|
||||||
if not self.__csock:
|
if not self.__csock:
|
||||||
return
|
return
|
||||||
if sendEnd:
|
try:
|
||||||
self.__csock.sendall(CSPROTO.CLOSE + CSPROTO.END)
|
self.__csock.sendall(CSPROTO.CLOSE + CSPROTO.END)
|
||||||
self.__csock.shutdown(socket.SHUT_RDWR)
|
self.__csock.shutdown(socket.SHUT_RDWR)
|
||||||
|
except socket.error: # pragma: no cover - normally unreachable
|
||||||
|
pass
|
||||||
|
try:
|
||||||
self.__csock.close()
|
self.__csock.close()
|
||||||
|
except socket.error: # pragma: no cover - normally unreachable
|
||||||
|
pass
|
||||||
self.__csock = None
|
self.__csock = None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in New Issue